Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3017113
  • 博文数量: 535
  • 博客积分: 15788
  • 博客等级: 上将
  • 技术积分: 6507
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-07 09:11
文章分类

全部博文(535)

文章存档

2016年(1)

2015年(1)

2014年(10)

2013年(26)

2012年(43)

2011年(86)

2010年(76)

2009年(136)

2008年(97)

2007年(59)

分类: 系统运维

2009-04-27 13:26:05

首先
做为loadblance的nginx要添加下面的配置:

proxy_set_header        Host $host;

proxy_set_header        X-Real-IP $remote_addr;

proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

X-Real-IP和X-Forwarded-For可以2选1,也可以都打开:

然后:
1.如果backend是apache时:apache需要添加模块rpaf
可以用于apache 2.2

Compile and Install for 1.3:
apxs -i -a -c mod_rpaf.c 

Compile and Install for 2.0:
apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c

or simply try:
make

Configuration Directives:
RPAFenable On
# Enable reverse proxy add forward
RPAFproxy_ips 127.0.0.1 10.0.0.1
# which ips are forwarding requests to us
RPAFsethostname On
# let rpaf update vhost settings 
# allows to have the same hostnames as in the "real"
# configuration for the forwarding Apache
RPAFheader X-Forwarded-For
# Allows you to change which header mod_rpaf looks
# for when trying to find the ip the that is forwarding
# our requests


# if DSO load module first: LoadModule rpaf_module libexec/apache2/mod_rpaf-2.0.so RPAFenable On RPAFsethostname On RPAFproxy_ips 192.168.1.23 (nginx loadblance server) RPAFheader X-Forwarded-For



2.如果是nginx做为backend的话:
做为backend的nginx在编译时需要添加模块
--with-http_realip_module
并修改nginx.conf:

   192.168.2.1;(该ip为nginx loadblance ip)
     X-Real-IP;
context为: http, server, location
更多,查看:

阅读(4592) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~