Forum Discussion
snowfly_86261
Nimbostratus
Mar 12, 2010replace http:// to https:// problems
Dear all,
I have a problem about it
My Topology as under
client <-- HTTPS --> F5-LTM <-- HTTP --> httpServer
(1) client type in https://www.domain.com/
(2) httpServer return 302 Not Found , and Location: http://www.domain.com/nsp/login?acct=a
(3) because the virutal server just service https, so the client not connect to "http://www.domain.com/nsp/login?acct=a"
so I want to replace the Location string to https://www.domain.com/nsp/login?acct=a when at (2).
Cloud you help me ?
- hoolio
Cirrostratus
You can create a custom HTTP profile with rewrite redirects enabled and add it to your VS to have LTM rewrite the http:// reference to https. You can check the online help on the HTTP profile page for details on the options.when HTTP_RESPONSE { Check if server response is a redirect if { [HTTP::header is_redirect]} { Log original and updated values log local0. "Original Location header value: [HTTP::header value Location],\ updated: [string map -nocase "http:// https://" [HTTP::header value Location]]" Do the update, replacing http:// with https:// HTTP::header replace Location \ [string map -nocase "http:// https://" [HTTP::header value Location]] } }
- snowfly_86261
Nimbostratus
Dear Aaron, - hoolio
Cirrostratus
Does the application actually include the :80 port number in the Location header value? If so, you'd need to use an iRule, I think:when HTTP_RESPONSE { Check if server response is a redirect if { [HTTP::header is_redirect]} { Log original and updated values log local0. "Original Location header value: [HTTP::header value Location],\ updated: [string map -nocase "http:// https:// :80/ /" [HTTP::header value Location]]" Do the update, replacing http:// with https:// and :80/ with / HTTP::header replace Location \ [string map -nocase "http:// https:// :80/ /" [HTTP::header value Location]] } }
- snowfly_86261
Nimbostratus
Dear Aaron, - JRahm
Admin
you could use [getfield [HTTP::header value Location] ":" 2] as a conditional and only perform the string map if it equals 80. - snowfly_86261
Nimbostratus
Dear citizen_elah - hoolio
Cirrostratus
As citizen_elah suggests, you could use getfield or check for :80/when HTTP_RESPONSE { Check if server response is a redirect and contains a reference to port 80 if { [HTTP::header is_redirect] && [HTTP::header value Location] contains ":80/"} { Log original and updated values log local0. "Original Location header value: [HTTP::header value Location],\ updated: [string map -nocase "http:// https:// :80/ /" [HTTP::header value Location]]" Do the update, replacing http:// with https:// and :80/ with / HTTP::header replace Location \ [string map -nocase "http:// https:// :80/ /" [HTTP::header value Location]] } }
You can check the online help on the HTTP profile page for details on the options.
If you need that link you can check it out here ! :)
https://devcentral.f5.com/articles/rewriting-redirects
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