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

(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.

最新文章

  1. 0030 Java学习笔记-面向对象-垃圾回收、(强、软、弱、虚)引用
  2. kali 2.0 U盘安装错误Your installation cd-rom couldn't be mounted
  3. 理解Android虚拟机体系结构
  4. UVa 12505 Searching in sqrt(n)
  5. asp.net 组织结构图控件
  6. 写一篇 Bootstrap弹窗确认的文章。本周完成
  7. 机器学习基石:14 Regularization
  8. Vue2学习(2)
  9. FM(Factorization Machines)
  10. verilog实现两个数的最大公因数
  11. WPF之UI虚拟化
  12. pandas 读mysql数据库(整个表或者表的指定列)
  13. Javascript 计算字符串所占字节数
  14. Android:percent 布局
  15. shell编程:for 循环
  16. 【DP】【CF1097D】 Makoto and a Blackboard
  17. python基本数据类型的用法和区别
  18. Ant简单工程的构建
  19. jenkins双向备份;高可用部署;
  20. 在cmd里面使用mysql命令

热门文章

  1. oracle 创建用户和imp指定表空间
  2. 试图加载格式不正确的程序。 (异常来自 HRESULT:0x8007000B)
  3. 国际化,java.util.ResourceBundle使用详解
  4. html5 上传头像的裁剪
  5. 封装ios静态库碰到的一些问题(一)
  6. java线程池初步理解
  7. mybatis报invalue types()错误
  8. 解决Android5.0以后DatePicker选择时间无效的bug。
  9. bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
  10. 微信小程序 wx.uploadFile在安卓手机上面the same task is working问题解决