Help needed with basic redirect.

Hi, Very new to bigip / iRules.

I am trying to get the following iRule working which was taken directly from this site, to redirect any http traffic to https on the same uri.

when HTTP_REQUEST {

HTTP::redirect https://[getfield [HTTP::host] “:” 1][HTTP::uri]

}

When I apply this rule to my virtual server then it doesn’t work for http, it also stops https working to the VIP as well.

Using a TCP dump on the box I get the following for http://

11:32:30.158337 arp who-has 192.168.1.72 tell 192.168.1.121

11:32:36.178106 arp who-has 192.168.1.72 tell 192.168.1.121

11:32:59.804371 arp who-has 192.168.1.72 tell 192.168.1.121

.72 is my VIP and .121 is the floating ip address of the external interfaces.

Using a TCP dump on the box I get the following for https://

11:32:26.560227 172.29.193.72.https > 159.167.245.212.2363: P 49470:49661(191) ack 109720 win 16384 (DF)

11:32:26.662324 159.167.245.212.2363 > 172.29.193.72.https: P 109720:110142(422) ack 49661 win 64385 (DF)

11:32:26.662510 172.29.193.72.https > 159.167.245.212.2363: P 49661:49852(191) ack 110142 win 16384 (DF)

11:32:26.784369 159.167.245.212.2363 > 172.29.193.72.https: P 110142:110564(422) ack 49852 win 64194 (DF)

11:32:26.784542 172.29.193.72.https > 159.167.245.212.2363: P 49852:50043(191) ack 110564 win 16384 (DF)

11:32:26.884329 159.167.245.212.2363 > 172.29.193.72.https: P 110564:110986(422) ack 50043 win 65340 (DF)

This keeps trying on https and never timing out.

I would like to implement other redirects from say https://mywebserv.com redirected to https://mywebserver.com/home/index.html but I cannot get this working either.

Any help would be greatly appreciated.

I use:

when HTTP_REQUEST { HTTP::redirect https://[HTTP::host][HTTP::uri]}

and it works great. You need an HTTP (80) virtual server with this iRule as a resource. You also need an HTTPS (443) virtual server with the same IP address. The HTTPS virtual server doesn’t need the iRule.

You can also change the “[HTTP::host][HTTP::uri]” part of the rule to a specific uri and it will work.

Hope this helps.

Thanks very much, it’s working now.

Yep; it’s built into HTTP classes in 9.4. I believe that it will be available for all LTM, as well as web accelerator and ASM.