Forum Discussion
Jure_48098
Nimbostratus
Feb 15, 2008SSL login redirect
I have a site that I'm tryng to migrate to LTM, that is running HTTP and HTTPS. The login POST always goes to the SSL server. Server then does the auhorisation and returns a HTTP 302 redirect with the Referer URL as the new Locaton (and some new cookie)..
In it's current version, there are some proxies in front of the application server (thar really does the content) and SSL is terminated there.
Now I terminate SSL on the LTM and have only the http proxy in between. The trouble is, that whenever a user logs in, he gets a 302 redirect to the HTTP site, because the server always returns a HTTP redirect (uses just the path part of Referer) and before the SSL proxy took care it remaped that to SSL if needed.
What I'd like to know, is there a way to keep state in an iRule of the Referrer location when the user request arrived and the server issues a response, so I could redirect the ones that have HTTPS referer to HTTPS and leave the HTTP ones as they are..
One other idea that comes to my mind is, to insert a ?ssl or something in the Referer header on the way in and delete it + redirect to SSL on the way out.
What is the best way to handle such an issue?
Thanks
Jure
- hoolio
Cirrostratus
Do you know what the logic was that the SSL proxy used? That should be something you could implement in an iRule without making any changes. Are the login requesta always made to the same URI (like /login.php, for example)? - Jure_48098
Nimbostratus
The login goes always to the same URI. - Nicolas_Menant
Employee
Hi, - hoolio
Cirrostratus
One suggestions on that. If the redirect location changes (ie, the URI is dynamically set) and you need to preserve this, you can replace the only host portion of the redirect with the FQDN using a rule like this:when HTTP_RESPONSE { if {[HTTP::is_redirect]}{ set domain_name "host.example.com" log local0. "\[IP::remote_addr\]:\[TCP::remote_port\]: [IP::remote_addr]:[TCP::remote_port]" set string_map [string map "[IP::remote_addr]:[TCP::remote_port] $domain_name" [HTTP::header value Location]] log local0. "string map: $string_map" HTTP::header replace Location [string map "[IP::remote_addr]:[TCP::remote_port] $domain_name" [HTTP::header value Location]] } }
when HTTP_RESPONSE { if {[HTTP::is_redirect]}{ HTTP::header replace Location [string map "[IP::remote_addr]:[TCP::remote_port] host.example.com" [HTTP::header value Location]] } }
- Jure_48098
Nimbostratus
Thank you for this. Unfortunately I can't just do an iRule Location rewrite if the reply is a 3XX redirect, because the response from the proxies to the LTM is the same whether the original request came from the SSL site or the HTTP one. I need to track and match: - hoolio
Cirrostratus
If you only want to rewrite some responses, based on request criteria, you could add logic to the HTTP_REQUEST event:when HTTP_REQUEST { if {[HTTP::method] eq "POST" and [HTTP::header value Referer] starts_with "https://"}{ set rewrite_redirect 1 } else { set rewrite_redirect 1 } } when HTTP_RESPONSE { if {[HTTP::is_redirect]}{ HTTP::header replace Location [string map "[IP::remote_addr]:[TCP::remote_port] host.example.com" [HTTP::header value Location]] } }
- Jure_48098
Nimbostratus
Thanks a lot. I ended up with an iRule that checks if the Referer starts with https + request is https and response is a redirect, then rewrite the Location to https as it turned out there were multiple 3XX pages..
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