Forum Discussion
DarkSideOfTheQ_
Nimbostratus
Jan 27, 2009genric http to https question
I've done a couple of http to https irules and now find mysyelf wondering if I can accomodate this new request. We are using a single hostname for different applications (ex. server1.domain.com/click/123456/789 or server1.domain.com/open/some.jpg) and they would like me to redirect these requests to https. Can I do a generic redirect for 'http://server1.domain.com' to 'https://server1.domain.com' without using a specific https url as I've done with the other rules I've created? (ex of what i've done previously with exact url http://server1.domain.com to https://server1.domain.com/login.do)
*NOTE: the example above 'server1.domain.com/click/123456/789' the variables after /click/ will change, depending on what one is viewing in the app.
I hope this makes sense???
TIA,
DarkSide
- hoolio
Cirrostratus
You can redirect to the same host and URI that the client requested:when HTTP_REQUEST { Check if Host header value has a length if {[string length [HTTP::host]]}{ Redirect to the requested host and URI (minus the port if specified) HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] } else { Redirect to VIP's IP address HTTP::redirect https://[IP::local_addr][HTTP::uri] } }
- Jennifer_Davis2
Nimbostratus
This matches all incoming HTTP traffic regardless of URL and redirects it to HTTPS. The redirect keeps the URL intact for the user and just redirects the port. - Deb_Allen_18Historic F5 AccountHey Jennifer, thanks for posting!
- DarkSideOfTheQ_
Nimbostratus
Yea, I saw this sample, but wasn't sure if it was too generic. We have a number of hostnames pointing to the same VIP (which is a resin cluster), but I only need to catch a specific one that may have a varying uri string. - DarkSideOfTheQ_
Nimbostratus
Ah-Ha...I was indeed headed down the right path. I had taken the example I found in the sample pages(the same one hoolio posted) and was trying to put together what you posted. I've had to shelve my new Powershell book (wanted to start learning that this year) in place of learning this TCL stuff. Slow going...I equate it to learning to speak a new language, but I know I'll get there eventually. - hoolio
Cirrostratus
It's also useful to consider HTTP 1.0 requests which may not contain a host header. If the client didn't include a host header in the request, and you redirected to https://[getfield [HTTP::host] ":" 1]][HTTP::uri]", the client would get a redirect to https:///whatever/uri/they/requested.html, instead of a valid FQDN.
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