Forum Discussion

Cae_140395's avatar
Cae_140395
Icon for Nimbostratus rankNimbostratus
Feb 18, 2014

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

  • 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_3's avatar
    Aaron_Forster_3
    Historic 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.

     

  • 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!

  • 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.

     

  • 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....