Forum Discussion
http 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 8080 with SSL offload
i_Rules:
when HTTP_REQUEST { HTTP::redirect https://[getfield [HTTP::host] : 1]:8080[HTTP::uri] }
Regards,
Goldz
Hi 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
is only required for HTTP/1.1 requests. To support HTTP/1.0 requests, you may want to replace the[HTTP::host]
syntax with a hardcoded string. You could also mix a dynamic redirect based on available[getfield [HTTP::host] ":" 1]
values and use a hard coded string as a fall back by using a if-then-else syntax.[HTTP::host]
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
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