阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

HAproxy 让后端RS记录真实IP

198次阅读
没有评论

共计 1173 个字符,预计需要花费 3 分钟才能阅读完成。

# 让 RS 记录客户端的真实 IP

#1. 先在 haproxy.cfg 中加入下面参数。

listen www

option forwardfor             
# 如果后端服务器需要获得客户端真实 ip 需要配置的参数,必须要放在 listen 模块下 

#2. 如果是 apache,则加入下面参数

LogFormat“\”%{X-Forwarded-For}i\”%l %t \”%r\” %>s %b \”%{Referer}i\”\”%{User-Agent}i\”” combined
主要是“\”%{X-Forwarded-For}i\ 这个参数可以记录 IP

#3. 如果是后端 RS 是 nginx 则加入下面参数

set_real_ip_from ip;(这个 ip 填写的是 proxy 的 ip)
 
real_ip_header X-Forwarded-For;

log_format main‘$remote_addr – $remote_user [$time_local]“$request”‘
‘$status $body_bytes_sent“$http_referer”‘
‘”$http_user_agent”“$http_x_forwarded_for”‘
=============================================
在 log_format 里添加 $remote_addr 或者 $http_x_forwarded_for 参数。

Haproxy+Keepalived 搭建 Weblogic 高可用负载均衡集群 http://www.linuxidc.com/Linux/2013-09/89732.htm

Keepalived+HAProxy 配置高可用负载均衡 http://www.linuxidc.com/Linux/2012-03/56748.htm

CentOS 6.3 下 Haproxy+Keepalived+Apache 配置笔记 http://www.linuxidc.com/Linux/2013-06/85598.htm

Haproxy + KeepAlived 实现 WEB 群集 on CentOS 6 http://www.linuxidc.com/Linux/2012-03/55672.htm

Haproxy+Keepalived 构建高可用负载均衡 http://www.linuxidc.com/Linux/2012-03/55880.htm

使用 HAProxy 配置 HTTP 负载均衡器 http://www.linuxidc.com/Linux/2015-01/112487.htm

HAproxy 的详细介绍 :请点这里
HAproxy 的下载地址 :请点这里

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2015-11/124951.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计1173字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中