博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Preserving Remote IP/Host while proxying
阅读量:4543 次
发布时间:2019-06-08

本文共 1857 字,大约阅读时间需要 6 分钟。

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

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

转载于:https://www.cnblogs.com/BigTall/p/3281688.html

你可能感兴趣的文章
基于unity3d IFC的虚拟仿真系统
查看>>
BCS SET EMAIL
查看>>
linux 2.6 驱动笔记(一)
查看>>
SpringMVC与MyBatis整合方法
查看>>
获取当前系统运行目录
查看>>
多个tomcat实例运行的配置
查看>>
一种基于 Numpy 的 TF-IDF 实现报告
查看>>
wpf窗口阴影
查看>>
linux内核分析第四周-使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用...
查看>>
Centos 7升级内核
查看>>
Pandas 基本技巧
查看>>
hdu 1264
查看>>
hdu 1273不会的题
查看>>
(转)父子窗体的菜单合并及工具栏合并
查看>>
分页SQL
查看>>
linux系统使用sh文件传参数给matlab程序
查看>>
软工实践原型设计-黄紫仪
查看>>
食用指南
查看>>
CSS3圆角详解(border-radius)
查看>>
Python正则表达式指南
查看>>