开发者

Django: request.META['REMOTE_ADDR'] is always '127.0.0.1'

I have an applicati开发者_StackOverflow中文版on running with debug=True on a remote host somewhere. Now somehow every time I access REMOTE_ADDR it returns 127.0.0.1 no matter where the request is from.

I'm not sure where to start and why this is happening.


Do you have any kind of proxy, gateway, or load balancer running on that remote host? That's the sort of thing that would cause connections to appear to be from 127.0.0.1 (because that's where the immediate connection is from, as far as the web server is concerned).


If you are behind a proxy and running apache as the webserver you could use mod_rpaf. The proxy only needs to send X-Forwarded-For or X-Real-IP headers.

http://stderr.net/apache/rpaf/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜