How to make sure that my AJAX requests are originating from the same server in Python

后端 未结 8 1945
故里飘歌
故里飘歌 2021-01-31 18:30

I have already asked a question about IP Authentication here: TastyPie Authentication from the same server

However, I need something more! An IP address could be very e

8条回答
  •  天命终不由人
    2021-01-31 19:05

    If this app server is running on an ordinary web server that has configurable listening IP address, set it to 127.0.0.1. With the TCPServer module, it's like

    SocketServer.TCPServer(("127.0.0.1", 12345), TheHandlerClass)

    Use netstat command to verify the listening address is correct as "127.0.0.1"

    tcp4 0 0 127.0.0.1.12345 *.* LISTEN

    This will effectively making any connection originated outside the same host impossible on the TCP level.

提交回复
热议问题