Add the following configuration under the front-end bind in the Haproxy configuration file:
Http-request Set-header ZXTMIP%[SRC]
PS: Where ZXTMIP is the custom field%[SRC] is to get IP
Test results:
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "spacer.gif"/> The output after opening the test domain in the browser is as follows:
Array ([TEMP] =/var/tmp [TMPDIR] =/var/tmp [tmp] = =/var/tmp [PATH] =/usr/local/bin:/usr/bin:/bin [HOST NAME] = + mptest.okooo.com [USER] + web [HOME] +/var/webroot [fcgi_role] = RESPONDER [Script_filename] => ; /home/oae/web/wwwroot/public/index.php [Query_string] = [Request_method] + GET [content_type] = [CONTENT_ LENGTH] = [Script_name] =/index.php [Request_uri] =/[Document_uri] =/index.php [Document_root] =/ Home/oae/web/wwwroot/public [Server_protocol] = http/1.1 [Gateway_interface] = cgi/1.1 [Server_software] = = nginx/1.6.2 [REMOTE_ADDR] = 192.168.1.231 [Remote_port] = 6824 [SERVER_ADDR] = 192.168.1.235 [Server_port] =& Gt [server_name] = mptest.okooo.com [Redirect_status] = [Http_host] = mptest.okooo.com [Http_upgrade_ Insecure_requests] + 1 [http_user_agent] = mozilla/5.0 (Windows NT 10.0; Win64; x64) applewebkit/537.36 (khtml, like Gecko) chrome/60.0.3112.78 Safari/537.36 [http_accept] = Text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q =0.8 [http_accept_encoding] = gzip, deflate [http_accept_language] = zh-cn,zh;q=0.8 [Http_cookie] = lasturl= ; __utma=56961525.524112254.1501123742.1501123742.1501123742.1; __utmz=56961525.1501123742.1.1.utmcsr= (direct) |utmccn= (direct) |utmcmd= (none) [HTTP_ZXTMIP] = 111.200.213.110 [ Http_x_forwarded_for] = 111.200.213.110 [Http_connection] = close [php_self] =/index.php [request_time_ FLOAT] = 1501644453.5864 [Request_time] = 1501644453)
This article is from the "Dr Small White" blog, please be sure to keep this source http://1213503.blog.51cto.com/1203503/1952946
Haproxy Add back-end User real IP in HTTP header