Monday, 27 July 2020

How-to: Add X-Forwarded-Proto in FortiADC

The FortiADC allows you to add X-Forwarded-Proto headers to server requests using scripting.

To do this, add a new script under Server Load Balance > Scripting and create a new script with the following:

when HTTP_REQUEST{
 host = HTTP:header_get_value("Host")
 if host:lower():find("adc.fortilab.local") then
  log("found adc.fortilab.local in Host %s \n", host)
  HTTP:header_insert("X-Forwarded-Proto", "https")
 end
}

Enable the script in your virtual server by going to Server Load Balance > Virtual Server. Edit your virtual server and select the General tab and select your script.



Now when you access the web server the X-Forwarded-Proto header will be sent to the server.