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

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

Preserving Remote IP/Host while proxying的更多相关文章

  1. How To Monitor Remote Linux Host using Nagios 3.0

    In the previous post Nagios 3.0 Jumpstart guide , I explained the overview, installation and configu ...

  2. zabbix_server.log大量提示cannot send list of active checks to "IP": host [HostName] not found

    zabbix server 日志大量提示上图信息 原因是 zabbix_agent.conf配置文件中配置的HostName与zabbix的web界面配置的不同导致的 zabbix_agent.con ...

  3. linux设置允许和禁止访问的IP host.allow 和 host.deny

    对于能过xinetd程序启动的网络服务,比如ftp telnet,我们就可以修改/etc/hosts.allow和/etc/hosts.deny的配制,来许可或者拒绝哪些IP.主机.用户可以访问. 比 ...

  4. MapReduce 踩坑 :Aggregation is not enabled. Try the nodemanager at IP:HOST

    原因:yarn-site.xml 中,有关mapreduce日志查看的aggregation未配置启用 解决:在yarn-site.xml 中加入以下配置 <property> <n ...

  5. 一个简单的JAVA C/S多线程应用

      import java.net.*;import java.io.*;public class simpleServer{private static ServerSocket serverSoc ...

  6. broadcom移植到openwrt总结

    评估及移植BCM5862x及BCM5301x到openwrt平台下: 一.首先得分清楚几个基本概念: 1.文件系统  文件系统是操作系统用于明确存储设备(常见的是磁盘,也有基于NAND Flash的固 ...

  7. 用TTL线在CFE环境下拯救半砖wrt54g路由器

    缘起:路由器被刷成半砖 Linksys wrt54gs v4路由器,已刷入 tomato-dualwlan 1.23.使用数年,未出现任何故障. 在日用的wifi网络上,通过web界面刷入了错误的to ...

  8. Vue 项目代理设置的优化

    Vue 项目代理设置的优化 Vue 类的项目开发中项目结构基本都是类似于 Vue-cli 生成的方式, 这种方式开发中,最常用到的模式是开启代理进行 mock 调试或远程调试, 也就是使用了 Vue- ...

  9. Mininet 创建topo的时候指定host的ip

    示例,要创建一个3个交换机8个主机的拓扑,如下图: 可以用如下python代码创建上述拓扑,并指定ip: from mininet.topo import Topo class MyTopo( Top ...

随机推荐

  1. [php-src]窥探Php内核中的数组与面向对象

    内容均以php5.6.14为例. 扩展中定义一个类有以下四步: #1. 声明一个存储类信息的指针. zend_class_entry *errs_ce; #2. 定义方法的参数信息,类的方法实现. Z ...

  2. CSS3制作各种形状图像

    圆形-椭圆形-三角形-倒三角形=左三角形-右三角形-菱形-平行四边形- 星形-六角星形-五边形-六边形-八角形-心形-蛋形-无穷符号-消息提示框 不废话直接 html界面(亲测的) ------转自百 ...

  3. javascript中关于深复制与浅复制的问题

    在javascript中,变量的类型分为基本类型和引用类型. 对于基本类型的变量来说,值的复制以及作为函数参数实参传递的过程都是值的复制传递,换句话说,是会在内存中开辟出一个新空间用于存放新的值的.这 ...

  4. Spring overview

    引子 接触Java很多年了,各种framework,却从未系统的去了解过.最近突然想清楚一件事,就是当下的目标——Focus on Java-based RESTful WS & JS.而之于 ...

  5. 通过Guid获取DirectoryEntry对象

    绑定DirectoryEntry对象通常有两种方法,一种是通过字符串(如通过ADsPath),一种是通过Guid(参见:http://msdn.microsoft.com/zh-cn/library/ ...

  6. java excle导出合计字段值

    效果图: 代码实现: 解释: // 四个参数分别是:起始行,起始列,结束行,结束列 sheet.addMergedRegion(new Region(0, (short) (celln + 1), 0 ...

  7. ubuntu 安装JAVA jdk的两种方法:

    ubuntu 安装jdk 的两种方式: 1:通过ppa(源) 方式安装. 2:通过官网下载安装包安装. 这里推荐第1种,因为可以通过 apt-get upgrade 方式方便获得jdk的升级 使用pp ...

  8. 关于mha手动切换的一些记录(mha方案来自网络)

    mha方案出自:http://www.cnblogs.com/xuanzhi201111/p/4231412.html 当主服务器故障时,人工手动调用MHA来进行故障切换操作,具体命令如下: 先停MH ...

  9. IE跨域访问问题

    可能出现的症状: 1.跨域无法登录. 2.同一页面请求同一域名SESSION无法获取.(SESSION_ID一直在变) 一般情况下在方法前加上以下代码: header("P3P: CP=CU ...

  10. tomee 消息持久化

    http://tomee.apache.org/jms-resources-and-mdb-container.html http://activemq.apache.org/xml-configur ...