<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[SOLVED] HaProxy forward client IP]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I am running haproxy -&gt; (192.168.80.90) on pfsense -&gt; (192.168.80.1), In frontend I have checked the “Use “forwardfor” option.” But instead haproxy forwards the 192.168.80.1 address, instead of the clients ip.</p>
<p dir="auto"><strong>Look for frontend <span style="color:#c82d2d">FrontEndProxy</span></strong></p>
<p dir="auto">Thanks,</p>
<pre><code># Automaticaly generated, dont edit manually.
# Generated on: 2020-12-31 02:42
global
	maxconn			1000
	log			/var/run/log	local0	info
	stats socket /tmp/haproxy.socket level admin  expose-fd listeners
	uid			80
	gid			80
	nbproc			1
	nbthread			1
	hard-stop-after		15m
	chroot				/tmp/haproxy_chroot
	daemon
	tune.ssl.default-dh-param	2048
	server-state-file /tmp/haproxy_server_state

listen HAProxyLocalStats
	bind 127.0.0.1:2200 name localstats
	mode http
	stats enable
	stats admin if TRUE
	stats show-legends
	stats uri /haproxy/haproxy_stats.php?haproxystats=1
	timeout client 5000
	timeout connect 5000
	timeout server 5000

frontend FrontEndProxy
	bind			192.168.80.90:443 name 192.168.80.90:443   ssl crt-list /var/etc/haproxy/FrontEndProxy.crt_list  
	mode			http
	log			global
	option			socket-stats
	option			http-keep-alive
	option			forwardfor
	acl https ssl_fc
	http-request set-header		X-Forwarded-Proto http if !https
	http-request set-header		X-Forwarded-Proto https if https
	timeout client		30000
	acl			speed	var(txn.txnhost) -m str -i speed.manjot.net
	acl			auth	var(txn.txnhost) -m str -i auth.manjot.net
	acl			jellyfin	var(txn.txnhost) -m str -i jellyfin.manjot.net
	acl			aclcrt_FrontEndProxy	var(txn.txnhost) -m reg -i ^speed\.manjot\.net(:([0-9]){1,5})?$
	acl			aclcrt_FrontEndProxy	var(txn.txnhost) -m reg -i ^auth\.manjot\.net(:([0-9]){1,5})?$
	acl			aclcrt_FrontEndProxy	var(txn.txnhost) -m reg -i ^jellyfin\.manjot\.net(:([0-9]){1,5})?$
	http-request set-var(txn.txnhost) hdr(host)
	use_backend Speed_ipvANY  if  speed aclcrt_FrontEndProxy
	use_backend Auth_ipvANY  if  auth aclcrt_FrontEndProxy
	use_backend Jellyfin_ipvANY  if  jellyfin aclcrt_FrontEndProxy

frontend HTTP-TO-HTTPS
	bind			192.168.80.90:80 name 192.168.80.90:80   
	mode			http
	log			global
	option			http-keep-alive
	option			forwardfor
	acl https ssl_fc
	http-request set-header		X-Forwarded-Proto http if !https
	http-request set-header		X-Forwarded-Proto https if https
	timeout client		30000
	http-request redirect scheme https 

frontend GMFrontEndProxy
	bind			192.168.80.39:443 name 192.168.80.39:443   ssl crt-list /var/etc/haproxy/GMFrontEndProxy.crt_list  
	mode			http
	log			global
	option			http-keep-alive
	timeout client		30000
	acl			gm	var(txn.txnhost) -m str -i gm.manjot.net
	acl			aclcrt_GMFrontEndProxy	var(txn.txnhost) -m reg -i ^gm\.manjot\.net(:([0-9]){1,5})?$
	http-request set-var(txn.txnhost) hdr(host)
	use_backend GM_ipvANY  if  gm aclcrt_GMFrontEndProxy

frontend GM-HTTP-TO-HTTPS
	bind			192.168.80.39:80 name 192.168.80.39:80   
	mode			http
	log			global
	option			http-keep-alive
	timeout client		30000
	http-request redirect scheme https 

backend Speed_ipvANY
	mode			http
	id			100
	log			global
	timeout connect		30000
	timeout server		30000
	retries			3
	option			httpchk OPTIONS / 
	server			speed 192.168.80.74:443 id 101 ssl check-ssl check inter 1000  verify none crt /var/etc/haproxy/server_clientcert_5f5d1c960d78a.pem 

backend Auth_ipvANY
	mode			http
	id			104
	log			global
	timeout connect		30000
	timeout server		30000
	retries			3
	option			httpchk OPTIONS / 
	server			Auth 192.168.80.73:443 id 105 ssl check-ssl check inter 1000  verify none crt /var/etc/haproxy/server_clientcert_5f5f10b443a8f.pem 

backend Jellyfin_ipvANY
	mode			http
	id			106
	log			global
	timeout connect		30000
	timeout server		30000
	retries			3
	server			jellyfin 192.168.80.18:8920 id 107 ssl check-ssl check inter 1000  verify none crt /var/etc/haproxy/server_clientcert_5f8a7e8154947.pem 

backend GM_ipvANY
	mode			http
	id			102
	log			global
	timeout connect		30000
	timeout server		30000
	retries			3
	option			httpchk OPTIONS /si/home.do 
	server			GM 192.168.80.38:9001 id 103 check inter 1000
</code></pre>
]]></description><link>https://forum.netgate.com/topic/159562/solved-haproxy-forward-client-ip</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Apr 2026 09:24:55 GMT</lastBuildDate><atom:link href="https://forum.netgate.com/topic/159562.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 01 Jan 2021 01:00:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] HaProxy forward client IP on Sat, 05 Nov 2022 00:09:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/braunerroei">@<bdi>braunerroei</bdi></a> Then your frontend config looks like this?</p>
<p dir="auto"><img src="/assets/uploads/files/1667605762622-196c1e01-1e74-49f5-87c8-4d22eb7bf590-image.png" alt="196c1e01-1e74-49f5-87c8-4d22eb7bf590-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">That's the SSL Offloading I was talking about. If you don't check that box, then pfSense won't negotiate SSL. I was worried that you might be processing unencrypted.</p>
<p dir="auto">In any event, I resolved my 503 problems. I'm not using the default port 443 for this new connection. Therefore, the value of the "Host Matches" ACL entry needed to be <em>my.host.com:6407</em>.  I had used <em>my.host.com</em> with no port.</p>
<p dir="auto">I had assumed that HAProxy would tack the port number on to the value because the port number is specified in the external address table. I see now it can't do that. The External Address table may contain multiple entries. It follows that the ACL match routine has no way to know your intentions unless you specify the port number in the ACL.</p>
<p dir="auto">Thanks for the help. Your answers got me questioning my own configuration which turned out to be in error.</p>
]]></description><link>https://forum.netgate.com/post/1069462</link><guid isPermaLink="true">https://forum.netgate.com/post/1069462</guid><dc:creator><![CDATA[bigtfromaz]]></dc:creator><pubDate>Sat, 05 Nov 2022 00:09:00 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] HaProxy forward client IP on Fri, 04 Nov 2022 16:26:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bigtfromaz">@<bdi>bigtfromaz</bdi></a></p>
<p dir="auto">In the matter af fact, I use the certificate stored on the pfSense, that was created by ACME.</p>
<p dir="auto">-Roei</p>
]]></description><link>https://forum.netgate.com/post/1069410</link><guid isPermaLink="true">https://forum.netgate.com/post/1069410</guid><dc:creator><![CDATA[braunerroei]]></dc:creator><pubDate>Fri, 04 Nov 2022 16:26:49 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] HaProxy forward client IP on Fri, 04 Nov 2022 16:22:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/braunerroei">@<bdi>braunerroei</bdi></a></p>
<p dir="auto">I assume you are storing your certificate on the Synology's box. If not, how are you securing your connection?</p>
<p dir="auto">I have the HAProxy frontend handling SSL negotiation using a certificate stored on the pfSense router. The certificate is acquired using the ACME package, configured to use Let's Encrypt DNS-01 protocol. This way we don't have to expose any ports when renewing our certificate. In this scenario, SSL offload is not from pfSense to Synology. It's the other way around. Our HAProxy frontend is listening on a custom port, negotiating the encrypted connection and forward traffic to the Synology backend which listening, unsecured, on a 5xxx port.</p>
<p dir="auto">I have the exact same configuration working (using different ports) for our Docker repository, without checking the forward for box.  It works fine. In that case the frontend port is 443 and the backend port is in the 5xxx range.</p>
<p dir="auto">It appears I need to open a ticket with Synology to see if they can help me find logs. I'm also having trouble getting detailed logs from HAProxy on pfSense.</p>
]]></description><link>https://forum.netgate.com/post/1069408</link><guid isPermaLink="true">https://forum.netgate.com/post/1069408</guid><dc:creator><![CDATA[bigtfromaz]]></dc:creator><pubDate>Fri, 04 Nov 2022 16:22:52 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] HaProxy forward client IP on Fri, 04 Nov 2022 07:58:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bigtfromaz">@<bdi>bigtfromaz</bdi></a><br />
Hi</p>
<p dir="auto">I am not pfSense / Haproxy expert, but it seems to be very easy.</p>
<p dir="auto">Why https offload to http backend?</p>
<p dir="auto">I configured backend with port 5001, and 2 frontends, one (shared) with 443 port and one with 5001 port, both use the same backend.</p>
<p dir="auto">-Roei</p>
]]></description><link>https://forum.netgate.com/post/1069348</link><guid isPermaLink="true">https://forum.netgate.com/post/1069348</guid><dc:creator><![CDATA[braunerroei]]></dc:creator><pubDate>Fri, 04 Nov 2022 07:58:26 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] HaProxy forward client IP on Fri, 04 Nov 2022 00:27:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/braunerroei">@<bdi>braunerroei</bdi></a> I curious, how did you get HAProxy in front of Synology to work? Is there an article somewhere that lays it out?  Frontend-backend relation seems to be correct. It's working for our private Docker registries but when I set up https offload to http backend Synology, I just get 503s. "Use forwardfor" is checked and the front-end and backend are green in the stats.</p>
]]></description><link>https://forum.netgate.com/post/1069324</link><guid isPermaLink="true">https://forum.netgate.com/post/1069324</guid><dc:creator><![CDATA[bigtfromaz]]></dc:creator><pubDate>Fri, 04 Nov 2022 00:27:47 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] HaProxy forward client IP on Tue, 26 Jul 2022 17:45:39 GMT]]></title><description><![CDATA[<p dir="auto">for synology:<br />
just configure "Trusted Proxies" - Control Panel&gt; Security &gt; Trusted Proxies</p>
]]></description><link>https://forum.netgate.com/post/1053700</link><guid isPermaLink="true">https://forum.netgate.com/post/1053700</guid><dc:creator><![CDATA[braunerroei]]></dc:creator><pubDate>Tue, 26 Jul 2022 17:45:39 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] HaProxy forward client IP on Sat, 16 Jul 2022 14:38:39 GMT]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">Didn't work for me (both ways [frontend / backend]).</p>
<p dir="auto">I have Synology NAS behind my pfSense/HaProxy, and the Synology shows the pfSense IP and not the real client IP.</p>
<p dir="auto">-Roei</p>
]]></description><link>https://forum.netgate.com/post/1052103</link><guid isPermaLink="true">https://forum.netgate.com/post/1052103</guid><dc:creator><![CDATA[braunerroei]]></dc:creator><pubDate>Sat, 16 Jul 2022 14:38:39 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] HaProxy forward client IP on Thu, 16 Jun 2022 02:34:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/greenant">@<bdi>greenant</bdi></a></p>
<p dir="auto">if you have the <code>http_realip_module</code> available in nginx, then the config is even simpler, just add to <code>nginx.conf</code>:</p>
<pre><code>real_ip_header X-Forwarded-For;
real_ip_recursive on;
set_real_ip_from &lt;your proxy/CDN IP CIDR here&gt;;
</code></pre>
]]></description><link>https://forum.netgate.com/post/1046900</link><guid isPermaLink="true">https://forum.netgate.com/post/1046900</guid><dc:creator><![CDATA[GreenAnt]]></dc:creator><pubDate>Thu, 16 Jun 2022 02:34:52 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] HaProxy forward client IP on Thu, 16 Jun 2022 02:29:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/manjotsc">@<bdi>manjotsc</bdi></a></p>
<p dir="auto">some further notes on this:</p>
<ul>
<li>the <code>forwardfor</code> option in the HAProxy front-end config works fine for forwarding the client address</li>
<li>you can use the backend option but I don't think it's necessary.</li>
</ul>
<p dir="auto">For users using <code>nginx</code>.  A similar logging can be achieved by:</p>
<p dir="auto">add this to <code>/etc/nginx/nginx.conf</code> in the <code>http {</code> block:</p>
<pre><code>    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    log_format combined_realip '$http_x_forwarded_for - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent"';

</code></pre>
<p dir="auto">then in your virtualhost config:</p>
<pre><code>access_log      /var/log/nginx/access.log combined;
access_log      /var/log/nginx/access_realip.log combined_realip;
</code></pre>
<p dir="auto">the <code>access_realip.log</code> will then include the client address.  You can then use that to verify the HAProxy is passing through the variable properly.</p>
<p dir="auto">see this guide for reference: https://djangocas.dev/blog/nginx/nginx-access-log-with-real-x-forwarded-for-ip-instead-of-proxy-ip/</p>
]]></description><link>https://forum.netgate.com/post/1046899</link><guid isPermaLink="true">https://forum.netgate.com/post/1046899</guid><dc:creator><![CDATA[GreenAnt]]></dc:creator><pubDate>Thu, 16 Jun 2022 02:29:13 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] HaProxy forward client IP on Sat, 02 Jan 2021 16:51:00 GMT]]></title><description><![CDATA[<p dir="auto"><strong>Solved</strong></p>
<p dir="auto">Guide : https://www.digitalocean.com/community/questions/get-client-public-ip-on-apache-server-used-behind-load-balancer</p>
<p dir="auto">First you  need to set <strong>option forwardfor</strong> in each backend to have in HaProxy, under <strong>Advanced Settings</strong> then in <strong>Backend pass thru</strong> box put <strong>option forwardfor</strong> and hit save, Don't set forwardfor in frontend, then you need to enable "<strong>sudo a2enmod remoteip</strong>" in your apache2 server and edit config <strong>/etc/apache2/apache2.conf</strong> and add the following line at bottom of config, <strong>RemoteIPHeader X-Forwarded-For</strong> and in that same config locate the log file line : <strong>LogFormat "%h %l %u %t "%r" %&gt;s %O "%{Referer}i" "%{User-Agent}i"" combined</strong> and change <strong>%h</strong> to <strong>%a</strong> to see the ip in logs, like this <strong>LogFormat "%a %l %u %t "%r" %&gt;s %O "%{Referer}i" "%{User-Agent}i"" combined</strong> and restart your apache2 server and you are done and check your apache access logs and you should see public ip of clients.</p>
<p dir="auto"><img src="/assets/uploads/files/1609605502214-screenshot-2021-01-02-114223.png" alt="Screenshot 2021-01-02 114223.png" class=" img-fluid img-markdown" /></p>
<pre><code>[root@cPanel ~]# a2enmod remoteip
Enabling module remoteip.
To activate the new configuration, you need to run:
  systemctl restart apache2
[root@cPanel ~]# systemctl restart apache2
[root@cPanel ~]#
[root@cPanel ~]# nano /etc/apache2/apache2.conf 

LogFormat "%a %l %u %t \"%r\" %&gt;s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

# HaProxy Forward for Enable

RemoteIPHeader X-Forwarded-For

[root@cPanel ~]# systemctl restart apache2

</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1609605414685-screenshot-2021-01-02-114051.png" alt="Screenshot 2021-01-02 114051.png" class=" img-fluid img-markdown" /></p>
<pre><code>------------Before--------------- 

192.168.80.1 - - [02/Jan/2021:11:10:00 -0500] "GET / HTTP/1.1" 200 623 "-" "Mozilla/5.0 (Linux; Android 10; SM-G975W) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36"
192.168.80.1 - - [02/Jan/2021:11:10:00 -0500] "GET /style.css HTTP/1.1" 200 277 "https://speed.manjot.net/" "Mozilla/5.0 (Linux; Android 10; SM-G975W) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36"
192.168.80.1 - - [02/Jan/2021:11:10:02 -0500] "GET /favicon.ico HTTP/1.1" 200 112448 "https://speed.manjot.net/" "Mozilla/5.0 (Linux; Android 10; SM-G975W) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36"

---------- After --------------  

204.48.93.246 - - [02/Jan/2021:11:11:05 -0500] "GET / HTTP/1.1" 200 623 "-" "Mozilla/5.0 (Linux; Android 10; SM-G975W) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36"
204.48.93.246 - - [02/Jan/2021:11:11:06 -0500] "GET /favicon.ico HTTP/1.1" 200 112448 "https://speed.manjot.net/" "Mozilla/5.0 (Linux; Android 10; SM-G975W) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36"
</code></pre>
]]></description><link>https://forum.netgate.com/post/954692</link><guid isPermaLink="true">https://forum.netgate.com/post/954692</guid><dc:creator><![CDATA[manjotsc]]></dc:creator><pubDate>Sat, 02 Jan 2021 16:51:00 GMT</pubDate></item></channel></rss>