Forum Discussion
What's the meaning of " : 1" in irule-redirect HTTP to HTTPs
Hello all!
I have a doubt about a parameter on the irule below:
when HTTP_REQUEST { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] }
Why the two points following from number one and what is the meaning of (":") ?? Why i need this in my irule for do simple redirect from HTTP to HTTPs ?
Best Regards
6 Replies
- Mui_64918
Cirrus
Which version are you using? You dont have to use getfield. The following will work when HTTP_REQUEST { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } in the above example the ":" is the delimiter in the getfield and you are requesting first field in it. you dont have to do that as HTTP::host returns the hostname.
- Aaron_Forster_3Historic F5 Account
Check the description in the docs for getfield.
To extract only the hostname from the host header (strips any trailing ":" port specification)
HTTP::host returns the host portion. The 'host' portion of the request can include an optional port.
So if your application's non-https port is anything other than 80 the request will look like:
http://example.com:9090/path/to/page
https://[HTTP::host][HTTP::uri]
would then redirect the user to:
https://example.com:9090/path/to/page
which isn't going to work.
It's not neccesary if you are applying it to a VIP on port 80. If you leave in the getfield you can use it for vips on any port.
- Cae_140395
Nimbostratus
Mui,
I'am using BIG-IP LTM 11.5.0. In the irule that you passed the part "https://[HTTP::host][HTTP::uri]" should really be in quotes ?Tks again!
- Mui_64918
Cirrus
you dont need the quotes when HTTP_REQUEST { HTTP::redirect https://[HTTP::host][HTTP::uri] } as long as you are using standard service ports in teh front end you dont need to use getfield.
- Cae_140395
Nimbostratus
Thanks Mui and Aaron !It was useful informations !
- IheartF5_45022
Nacreous
Hi - even if you are using a standard port, some clients (not usually a browser - a probe for example) can choose to include a port number in a request, so if you want to be super-dooper correct use getfield to prevent https://site.com:80/blah from being returned in a Location header. Also as Aaron says - if you leave it in it's a one size fits all iRule....
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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