惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
B
Blog
S
SegmentFault 最新的问题
Vercel News
Vercel News
博客园 - 聂微东
宝玉的分享
宝玉的分享
C
Check Point Blog
有赞技术团队
有赞技术团队
IT之家
IT之家
V
V2EX
爱范儿
爱范儿
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
博客园 - 司徒正美
博客园_首页
Last Week in AI
Last Week in AI
博客园 - 叶小钗
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
F
Fortinet All Blogs
腾讯CDC
J
Java Code Geeks

博客园 - 老翅寒暑

AI模型的回调能力的理解和实现 关于AI时代的程序架构的变化 关于需求规范和需求评审的一点看法 关于低代码和无代码---喧嚣背后的致命问题 为Jekyll静态网站添加PlantUML插件 企业要为现金流建模 关于通用框架的一些想法 XenServer 5.5 断电重启虚拟机磁盘丢失的修复 Fix catalyst driver in Ubuntu 13.04 / 13.10 异步javascript的原理和实现 需求的最初形式:12306ng的需求小说 需求与设计过程(1)-用例 项目进度控制的技术 项目管理沙龙第十二次会议纪要--为没有共识的项目组定制敏捷方法 项目管理沙龙第十一次聚会纪要--当敏捷没有共识的时候 项目管理沙龙第十次聚会纪要-AOM项目的敏捷实践 项目管理沙龙第九次聚会纪要 项目管理沙龙第八次聚会纪要 项目管理沙龙第七次聚会纪要
Preserving Remote IP/Host while proxying
老翅寒暑 · 2013-08-25 · via 博客园 - 老翅寒暑

因为这个文章用一般手段看不到,所以摘录下来备用

(From http://kasunh.wordpress.com/2011/10/11/preserving-remote-iphost-while-proxying/)

You host your web application with a hosting provider. Your application log/access IP address of your users and you get 127.0.0.1 or some other private IP. Deja Vu? Most likely reason for the above scenario is your hosting provider is using a proxy and the proxy server sits in the same machine or in the same network. Under a such situation we end up using X-Forwarded-For header.

I am aware of two solutions to be used in such a proxy setup so the developer doesn’t have to end up using X-Forwarded-For header.

1.) When the proxy server is an Apache, using ProxyPreserveHost directive in mod_proxy.
This can be used to preserve the remote host not the remote ip. This is useful for situations where name based virtual hosting is used and the backend server needs to know the virtual name of host.
Open mod_proxy configuration file of your proxy server and enter directive, ProxyPreserveHost On, and restart your apache instance.

2.) When backend server is apache, use mod_rpaf
This apache module can be used to preserve both remote IP/HOST. Internally it uses X-Forwarded-For header to detect a proxy in it’s list of known proxies and reset the headers accordingly. This works with any proxy server in the front end provided that the proxy server sets X-Forwarded-For header. To use mod_rpaf, install and enable it in the backend server and add following directives in the module’s configuration.
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1

Remote IP is automatically preserved when RPAFenable On directive is used. RPAFsethostname On directive should be used to preserve host and RPAFproxy_ips is the list of known proxy ips.

Restart backend apache server and you are good to go.