How to set/provide X-Forwarded-* headers

Hi all,

I am running haproxy inside pfsense.

I need to provide X-Forwarded headers for an application (kimai 2) I just installed inside a container in my proxmox server. The app is running behind haproxy, so this is necessary in order for it to work properly. The app’s documentation provides instructions and a configuration example using nginx; see here and the screenshot below for details:

Could you please help me understand how to do this in haproxy?

What I have tried so far is to check the box “Use “forwardfor” option” under “advanced settings” in my frontend but this did not fix the issues I am having with the https url redirecting to http and the browser timing out when I try to reach the app. I guess there is something I need to do inside the app’s backend, but where exactly?

Thanks a lot in advance for any tips.

Hello,

You can add header on front or backend section (HAProxy version 2.4.0 - Configuration Manual)

Here you can set all headers you need,

http-request set-header X-Forwarded-Proto https if { ssl_fc } # For Proto
http-request add-header X-Real-Ip %[src] # Custom header with src IP
option forwardfor # X-forwarded-for

Check the doc to see if you can find the vars you need