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