Forum Discussion
Goldz_180077
Nimbostratus
Feb 04, 2019http to https port 8080 redirection
Hi F5 Team,
can you validate my irules, if correct.
I need to redirect my http(80) access to https(8080)
Setup:
VIP: 10.10.10.10 port 80 with redirection enable
VIP: 10.10.10.10 port 8...
Kai_Wilke
MVP
Feb 04, 2019Hi Goldz,
your iRule will do the trick.
Personally I would prefer to use quotation marks to clearly define the start and end of embedded string values.
when HTTP_REQUEST {
HTTP::redirect "https://[getfield [HTTP::host] ":" 1]:8080[HTTP::uri]"
}
In addition you may check if a 301 "Permanent Redirect" would be suitable for your website, so that you save a round trip on subsequent HTTP requests.
when HTTP_REQUEST {
HTTP::respond 301 "Location" "https://[getfield [HTTP::host] ":" 1]:8080[HTTP::uri]"
}
Also keep in mind, that sending a
[HTTP::host] is only required for HTTP/1.1 requests. To support HTTP/1.0 requests, you may want to replace the [getfield [HTTP::host] ":" 1] syntax with a hardcoded string. You could also mix a dynamic redirect based on available [HTTP::host] values and use a hard coded string as a fall back by using a if-then-else syntax.
when HTTP_REQUEST {
if { [HTTP::host] ne "" } then {
HTTP::respond 301 Location "https://[getfield [HTTP::host] ":" 1]:8080[HTTP::uri]"
} else {
HTTP::respond 301 Location "https://www.mysite.com:8080[HTTP::uri]"
}
}
Cheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
