cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

URL to URI redirect irule required

Sarovani
Cirrostratus
Cirrostratus

Hi Team ,

 

we have 2 different applications hosted on the server , that can be accessed through 2 URI :

/ckpartner

/cklauncher

 

On f5 we want to redirect all requests on www.example.fr to www.example.fr/ckpartner

 

www.example.fr/cklauncher do not have to be exposed on the Internet

 

Can you please help me with irule for this redirect .

8 REPLIES 8

Hello Chethan.

 

you could try with this irule

when HTTP_REQUEST { if { [HTTP::host] contains "www.example.fr" } { HTTP::uri /ckpartner } }

KR,

Dario.

Regards,
Dario.

Sarovani
Cirrostratus
Cirrostratus

@Dario

 

Thank you .

 

I have to modify this rule with few more if and else statements , Can you please help ?

 

 

1.Redirect all the request comming from specidic source IP : 10.10.10.10 or 10.10.10.0/24 to www.example.fr/ckpartner

 

Hello Chethan.

 

Below one example of using URI replacement (first statement) and redirect (second statement).

when HTTP_REQUEST { if { [HTTP::host] contains "www.example.fr" } { HTTP::uri /ckpartner } elseif { [IP::addr [IP::client_addr] equals 10.10.10.0/24] } { HTTP::redirect "http://www.example.fr/ckpartner/" } }

Note that in the redirect command you should use the adequate scheme (http:// or https://)

 

Please, don't forget to mark this answer as "the best" if it was helpful.

 

KR,

Dario.

Regards,
Dario.

Thanks Dario ,

 

I tested first irule , it did not work for us .

 

 

We want all the request comming to www.example.fr from specific source 10.10.10.1 to get redirected to www.example.fr/ckpartner/ and this should be logged . 

Can you please check if the below Irule we can achieve this ?

 

 

 

when HTTP_REQUEST {

 

if { ([IP::addr [IP::client_addr] equals 10.10.10.1]) && ([HTTP::host] starts_with "www.example.fr") } {

 

log local0.

 

set newUri [string map {"/" "ckpartner/"} [HTTP::uri]]

 

HTTP::uri $newUri

 

}

 

}

Try this

when HTTP_REQUEST { if { ([IP::addr [IP::client_addr] equals 10.10.10.1]) && ([HTTP::host] contains "www.example.fr") } { if { [HTTP::path] equals "/" } { HTTP::redirect "/ckpartner/" log local0. "Redirection to /ckpartner" } } }

KR,

Dario.

Regards,
Dario.

Thanks for your help ,

 

My requirement is currently working with below Irule but I would like to add Datagroup to below Irule so that I can filter more external IP's

Could you please help me modify this irule .

I tried but I got error "variable reference required preeciding $"

 

 

 

when HTTP_REQUEST {

if {

                 ([IP::client_addr] contains "10.10.10.1%70") && ([string tolower [HTTP::uri]] contains "/cklauncher/")

                                  }

                                               {

                drop

}                                                             

elseif { [string tolower [HTTP::path]] equals "/" && ( [IP::addr [IP::client_addr] equals 10.10.10.1%70]) } {

# redirect the request

log local0. "issuing redirect request to [HTTP::host][HTTP::uri] from [IP::client_addr]"

HTTP::redirect https://[getfield [HTTP::host] ":" 1]/ckpartner/

}

}

Jeromee
Nimbostratus
Nimbostratus

When clients attempt to access your secure_vs, you don’t want them to have to remember to type HTTPS before the web site, but you also don’t want to open port 80 (HTTP) on your web servers as that is just asking for trouble. To avoid this issue, you will be creating an HTTP virtual server that will redirect HTTP to HTTPS and the secure_vs official website

Thanks for your help ,

 

My requirement is currently working with below Irule but I would like to add Datagroup to below Irule so that I can filter more external IP's

Could you please help me modify this irule .

I tried but I got error "variable reference required preeciding $"

 

 

 

when HTTP_REQUEST {

if {

                 ([IP::client_addr] contains "10.10.10.1%70") && ([string tolower [HTTP::uri]] contains "/cklauncher/")

                                  }

                                               {

                drop

}                                                             

elseif { [string tolower [HTTP::path]] equals "/" && ( [IP::addr [IP::client_addr] equals 10.10.10.1%70]) } {

# redirect the request

log local0. "issuing redirect request to [HTTP::host][HTTP::uri] from [IP::client_addr]"

HTTP::redirect https://[getfield [HTTP::host] ":" 1]/ckpartner/

}

}