我有一个sockjs服务器,它位于haproxy之后。现在我需要一个客户端IP地址,但使用self.transport.getPeer()
我得到我的haproxy的IP。 Haproxy使用原始客户端的ip为请求添加X-Forward-For标头。
如何获取已在我的协议中发送到服务器的原始http请求?
class MyProtocol(LineReceiver):
def connectionMade(self):
# this next line only gives me the ip of my proxy
ip = self.transport.getPeer()
class MyFactory(protocol.ServerFactory):
protocol = MyProtocol
my_factory = MyFactory()
sockjs_factory = SockJSMultiFactory()
sockjs_factory.addFactory(my_factory, 'echo')
sockjs_service = internet.TCPServer(10000, sockjs_factory)
application = service.Application("frog32")
sockjs_service.setServiceParent(application)