【发布时间】:2011-06-20 07:10:51
【问题描述】:
我在 127.0.01:8000 的 localhost 中运行服务
我正在使用以下方式进行代理:
proxy_pass http://127.0.0.1:8000;
问题是我需要将用户的 IP 地址传递给服务。
有什么想法吗?
【问题讨论】:
标签: python django ubuntu nginx gevent
我在 127.0.01:8000 的 localhost 中运行服务
我正在使用以下方式进行代理:
proxy_pass http://127.0.0.1:8000;
问题是我需要将用户的 IP 地址传递给服务。
有什么想法吗?
【问题讨论】:
标签: python django ubuntu nginx gevent
我通过设置自定义标头将真实 IP 发送到 django:
proxy_set_header X-Real-IP $remote_addr;
request.META 中提供了这些标头
【讨论】:
request.META['HTTP_X_REAL_IP']从 Django 访问。
if 'X-Real-IP' in request.headers and request.headers['X-Real-IP']: ip_address = request.headers['X-Real-IP']