cancel
Showing results for 
Search instead for 
Did you mean: 

url redirect irule

Sam10
Altostratus
Altostratus

I am trying to get an irule working for redirecting a url to a different one.

 

When users connect *.host1.abc.com it needs to redirect to *.host2.xyz.com

 

when HTTP_REQUEST {

  if { [class match [string tolower [HTTP::host]] contains *.host1.abc.com redirect] } {

            *.host2.xyz.com

        #log local0. "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]" }

}

}

 

 

5 REPLIES 5

Sam10
Altostratus
Altostratus

i tried using the below irule no luck so trying to understand where my logic is failing. If i can get the working irule that would be great

 

when HTTP_REQUEST {

 if { [class match [string tolower [HTTP::host]] contains *.host1.abc.com ] } {

          { HTTP::redirect " *.host2.xyz.com" /[HTTP::uri]

       #log local0. "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]" }

 

 }

}

 

Hi Sam10,

 

Can you try this?

when HTTP_REQUEST { if { [string tolower [HTTP::host]] contains "host1.abc.com" } { set host [string map -nocase {"host1.abc.com" "host2.xyz.com"} [HTTP::host]] HTTP::redirect "http://$host[HTTP::uri]" } }

 

Sam10
Altostratus
Altostratus

No luck , still running into the issue , page cannot be displayed.

I see the response going to the backend server , but server never responding back. I see a syn from F5 ,after 3 TCP retransmission from F5 , no response from the server . F5 is closing the connection .

 

This is the request i see in wireshark from client to F5.

 

   GET / HTTP/1.1

Host: tools.host1.abc.com

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

Accept-Language: en-US,en;q=0.5

Accept-Encoding: gzip, deflate, br

Connection: keep-alive

Upgrade-Insecure-Requests: 1

 

 

But no response from the backend the server.

 

 

Sam10
Altostratus
Altostratus

and also need HTTPs url redirect,

Sam10
Altostratus
Altostratus

thankyou , finally got this working as expected.

 

  1. when HTTP_REQUEST {
  2. if { [string tolower [HTTP::host]] contains "host1.abc.com" } {
  3. set host [string map -nocase {"host1.abc.com" "host2.xyz.com"} [HTTP::host]]
  4. HTTP::redirect "http://$host[HTTP::uri]"
  5. }
  6. }