Forum Discussion
Doran_Lum_13484
Nimbostratus
Sep 04, 2017X-Forwarded for https
Hi all, we have an application on our server which can't determine if the request is https or http coming from F5. X-Forwarded option have been enabled but the issue still persist. Should
I hav...
Kai_Wilke
MVP
Sep 05, 2017Hi Doran,
you could streamline your iRule by moving the protocol enumeration into the
CLIENT_ACCEPTED event (triggered only once every TCP connection), store the enumeration result into a $variable and then reference the $variable on every subsequent HTTP_REQUEST event. This approach will greatly reduce the overhead for Keep-Alive-Connections.
when CLIENT_ACCEPTED {
if { [PROFILE::exists clientssl] } then {
set client_protocol "https"
} else {
set client_protocol "http"
}
}
when HTTP_REQUEST {
HTTP::header remove "X-Forwarded-Proto"
HTTP::header insert "X-Forwarded-Proto" $client_protocol
HTTP::header remove "X-Forwarded-Port"
HTTP::header insert "X-Forwarded-Port" [TCP::local_port]
}
Note: In addition you should review your application if it would introduce certain risks if the client sends handcrafted X-Forwarded-Proto and X-Forwarded-Port headers to your application. If this scenario introduce some risks or if you can figure out the assosiated risks, then make sure to
any existing [HTTP::header remove]
and X-Forwarded-Proto
headers before X-Forwarded-Port
your verified values...[HTTP::header insert]
Cheers, Kai
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
