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

(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. Spring.net 间接调用被AOP拦截的方法失效(无法进入aop的拦截方法)

    .下面的tx要定义 <objects xmlns="http://www.springframework.net" xmlns:db="http://www.spr ...

  2. (一)常用的CSS命名规则

    头:header 内容:content/container 尾:footer 导航:nav 侧栏:sidebar 栏目:column 页面外围控制整体布局宽度:wrapper 左右中:left rig ...

  3. 《UML大战需求分析》阅读笔记6

    流程分析三剑客之总结 顺序图,活动图相类似表示活动,状态机图表示状态.分析特点: 顺序图: 强调角色之间的交互,信息明确: 从上到下,从左到右,按时间顺序: 不适合表达复杂特殊情况(循环分支,条件分支 ...

  4. mysql字段类型

    会安装mysql,会几条sql语句,会jdbc,会hibernate配置,以为就会mysql了,最近几天面试被问到mysql的问题,无地自容,系统的学习一下. mysql优化之一,选择合适的而不是最大 ...

  5. VM12安装OS X10.11步骤及说明

    参考文献: 1. http://www.crsay.com/network/enable-hardware-based-dep.html 2. http://jingyan.baidu.com/art ...

  6. 用 R 进行高频金融数据分析简介

    作者:李洪成 摘自:http://cos.name/wp-content/uploads/2013/11/ChinaR2013SH_Nov03_04_LiHongcheng.pdf 高频数据 金融市场 ...

  7. RabbitMQ 记录

    RabbitMQ 中文文档 : http://rabbitmq.mr-ping.com/description.html 官方教程译文: 一 http://blog.csdn.net/xiaoxian ...

  8. CentOS详解top命令各个数据的含义

    最近在docker(宿主机是centos虚拟机)里安装gitlab,发现随着时间的运行,虚拟机的内存持续走高,运行几个小时之后内存已经爆掉了,putty远程处理于假死状态. 这个时候就需要查看内存进程 ...

  9. mac命令行常用

    1. 寻找文件命令 find . -name "*.txt" //.代表当前路径,意思是找到所有txt文件 2. ps -A | grep mysql //可以检查到mysql的进 ...

  10. Java HashMap的死循环

    在淘宝内网里看到同事发了贴说了一个CPU被100%的线上故障,并且这个事发生了很多次,原因是在Java语言在并发情况下使用HashMap造 成Race Condition,从而导致死循环.这个事情我4 ...