haproxy 让后端服务器记录用户的真是IP地址(记录在header头里)
这里我们在生产中遇到一个问题就是。我们有的用户会登录失败。但是并不是所有的用户登录失败(这里是能够正常访问网站)
所以这里想分析哪些用户登录失败,所以我们要记录他们这些登录失败的IP地址
这里我们的结构是这样的,前端的代理用的是haproxy
后端的是java 程序
所以我们要在ha里配置,让后端能够取到用户的真实IP地址
所以我们的配置就是
option http-server-close
option forwardfor
后端的代码里去head头里的X-Forwarded-For字段
参考链接是https://gist.github.com/PiBa-NL/d826e0d6b35bbe4a5fc3
To send the ip addres of the client/webbrowser to the server/webserver behind it there are a few options:
1- option forwardfor
2- send-proxy
3- source 0.0.0.0 usesrc clientip
1- option forwardfor
This is an easy option to configure in haproxy, it does require that http layer7 processing is used 'mode http' and the webserver/ webapplication that wants to log or use the ip of the client must use the http-header 'X-Forwarded-For' to read the clientip.
2- send-proxy / send-proxy-v2 / send-proxy-*
This is can be used both with mode tcp and http, it does however require that the server also understands the proxyprotocol. Some applications have added support for this protocol which adds a few bytes with ip information before the actual request.
3- source 0.0.0.0 usesrc clientip
This allows any application and any protocol to be used and see the actual client ip as the origin from the incomming connection.
It does however require to configure IPTABLES or IPFW or other firewall rules to capture reply-traffic, also the haproxy machine must be the defaultroute for the return traffic from the (web-)server.
参考文档是:
https://www.haproxy.com/doc/aloha/7.0/haproxy/http_rewriting.html#add-a-header-to-the-request
haproxy 让后端服务器记录用户的真是IP地址(记录在header头里)的更多相关文章
- F5中源地址转换(AutoMap)模式下后端服务器获取客户端真正的IP地址
F5中开启AutoMap,并传递X-Forwarded-For值 开启F5源地址转换"Auto Map" 方式一: 在http profile中开启X-Forwarded-For ...
- nginx做反向代理负载均衡 Java怎么获取后端服务器获取用户IP
nginx做反向负载均衡,后端服务器获取真实客户端ip 首先,在前端nginx上需要做如下配置: location / proxy_set_hearder host ...
- --with-http_realip_module选项(后台Nginx服务器记录原始客户端的IP地址 )
转自:http://blog.itpub.net/27043155/viewspace-734234/ 通过这个模块允许我们改变客户端请求头中客户端IP地址值(例如,X-Real-IP 或 X-For ...
- TFS应用层服务器获取F5用户的真实IP地址(高可用性)
当用户数量达到一定级别(例如2千)以上,为保证TFS系统的持续服务,最大程度减少因系统宕机对研发团队的影响,系统管理员一般会考虑应用层和数据库层的高可用性方案. 在应用层的高可用性方案中,目前比较常见 ...
- 【Go】获取用户真实的ip地址
原文链接:https://blog.thinkeridea.com/201903/go/get_client_ip.html 用户请求到达提供服务的服务器中间有很多的环节,导致服务获取用户真实的 ip ...
- 获得用户的真实IP地址
/** * 获得用户的真实IP地址 * * @access public * @return string */if (!function_exists('get_real_ip')){ functi ...
- PHP获取用户的真实IP地址
本文出至:新太潮流网络博客 PHP获取用户的真实IP地址,非代理IP function getClientIP(){ global $ip; if(getenv("HTTP_CLIENT_I ...
- PHP获得用户的真实IP地址
<?php /** * 获得用户的真实IP地址 * * @access public * @return string */ function real_ip() { static $reali ...
- js记录用户在网站的浏览记录和停留时间
by weber开发者 from http://weber.pub/ 本文地址: http://weber.pub/js记录用户行为浏览记录和停留时间/163.html 问题 公司想统计一个用户从进入 ...
随机推荐
- React-Native视频组件react-native-video使用(安卓版)
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/7366019.html 一:安装 在IDE中打开你的项目,然后在IDE的terminal,输入: npm i - ...
- JQuery EasyUI学习笔记
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6690888.html 简介与准备 jQuery EasyUI 是一个基于 jQuery 的框架,集成了各种用 ...
- OpenERP 7中 openerp-server.conf 的解释
服务器启动配置 – 通用项 程序代码: [选择] # Admin password for creating, restoring and backing up databases admin_pas ...
- POJ--2406Power Strings+KMP求字符串最小周期
题目链接:点击进入 事实上就是KMP算法next数组的简单应用.假设我们设这个字符串的最小周期为x 长度为len,那么由next数组的意义,我们知道len-next[len]的值就会等于x.这就是这个 ...
- kettle Spoon.bat运行闪退
1.情景展示 启动kettle的Spoon.bat闪退,并没有进入kettle的启动界面. 2.原因分析 使用条件: jdk版本需>=1.6: java需配置环境变量. 如果满足了上述前提条 ...
- 〖Linux〗bash和expect执行ssh命令行sshcmd.exp
#!/usr/bin/expect -f # sudo apt-get install expect # ./ssh.exp user passwd server set user [lrange $ ...
- VTK中获取STL模型点的坐标以及对其进行变换
VTK是一个基于面向对象的开源三维绘图软件包,和其它的的三维绘图引擎如OSG.OGRE不同之处在于,VTK可视化对象主要是各种数据,更加注重对数据分析处理后的可视化,可视化的内容是人们无法直接感受到的 ...
- VTK中导入并显示STL、3DS文件
VTK(visualization toolkit)是一个开源的免费软件系统,主要用于三维计算机图形学.图像处理和科学计算可视化.VTK是在三维函数库OpenGL 的基础上采用面向对象的设计方法发展起 ...
- Redis从入门到精通:初级篇(转)
原文链接:http://www.cnblogs.com/xrq730/p/8890896.html,转载请注明出处,谢谢 Redis从入门到精通:初级篇 平时陆陆续续看了不少Redis的文章了,工作中 ...
- 设置char变量指定位为0或1
int GetBit(char c,int i)//取c的第i位 { ; } void SetBit(char & c,int i, int v)//设置c的第i位为v,v是0或1 { if( ...