如何将远程 IP 传递给代理服务?- Nginx [英] How to pass the remote IP to a proxied service? - Nginx
本文介绍了如何将远程 IP 传递给代理服务?- Nginx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在本地主机中运行服务 127.0.01:8000
I'm running a service in localhost at 127.0.01:8000
我通过使用代理:
proxy_pass http://127.0.0.1:8000;
问题是我需要将用户的 IP 地址传递给服务.
有什么想法吗?
推荐答案
我通过设置自定义标头将真实 IP 发送给 django:
I send the real IP to django by setting a custom header:
proxy_set_header X-Real-IP $remote_addr;
那些标头在 request.META
这篇关于如何将远程 IP 传递给代理服务?- Nginx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文