Forum Discussion
Redirect HTTP to HTTPS
Hello DC,
I'm new with F5 iRule. And right now, I have an application using http port 8080 and I would like to use SSL offload between client to F5 and keep the same port 8080 with https.
I create a VS using SSL and port 8080. It's working to display a login page with URL (), but when we logged in the application redirect to http and port 8080 () then I need to insert https manually on URL then it's working.
So, I would like to ask anyone can provide me the sample iRule to insert HTTPS when we perform logged in.
Thanks,
Phaneath
- jaikumar_f5
Noctilucent
This has been asked often and multiple threads are there.
Offloading SSL traffic causes improper redirects or links to HTTP
The solution was to update the http response headers, something like below.
when HTTP_RESPONSE { if { ( [HTTP::header exists Location] ) and ( [HTTP::header Location] contains "http://" ) } { HTTP::header replace [string map -nocase {"http://" "https://"} [HTTP::header Location]] } }
- youssef1
Cumulonimbus
Hi Phaneath,
Your problem is that your application use Absolute Path instead Relative Path.
It seems that in your application you have some uri set like that:
Examples: instead: Examples:
https://devcentral.f5.com/questions/rewrite-absolute-uri-to-relative-uri
Regards,
- quantiti_170569
Nimbostratus
You should create a Virtual Server listen on 8080 without SSL offload and assign an irule/LTM policty to redirect all HTTP request to HTTPS request at another port ( e.g 8443).
when HTTP_REQUEST { HTTP::redirect "https://[HTTP::host]:8443[HTTP::uri]" }
Create another Virtual Server listen on another port (8443) with SSL offload and assign this irule to rewrite redirect port if has
when HTTP_RESPONSE { Check if server response is a redirect if { [HTTP::header is_redirect]} { HTTP::header replace Location https://[string map {"http://" ""} [string map ":[TCP::remote_port]/ :8443/" [HTTP::header value Location]]] } }
- Phaneath_Phour1
Nimbostratus
Hello Quantiti,
It fixed my problem with iRule now. Thank you so much!!
Best Regards, Phaneath
Recent Discussions
Related Content
* 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