http forwarding with irule

hello,

I will confiugure a irule to forward to specific URL

the connection will be open to my VIP https://server1.com/123/456.html

and the BIGIP should forward this to http://testserver.de/123/456.html

my suggestion

when HTTP_REQUEST {

if { [HTTP::host] matches_regex “server1.com” } {

and now forward to http://testserver.de[HTTP::uri]

}

}

please help

Hi there

Do you wish to forward the traffic to the second server or redirect the client to that second server?

If you are forwarding the traffic - then the second server could just be in a bigip pool that is referenced either by the irule or as a default pool for the VS.

If you are redirecting have a look at the HTTP::redirect function as this should be able to work.

I hope this helps

hello

Ok, a redirect is not possible because the client should open the connection to testserver1.de about the VIP on the LB https://server1.com

This is like a tunneling

the client shouldn’t notice does he connecting another host

Thanks

sorry to adjustment

the client shouldn’t notice does he get data from another host

Do you need to forward using the DNS name (testserver.de)?

If you can use the IP address instead, you could simply do the following since you are not changing the URI:

when HTTP_REQUEST {         
        if { [HTTP::host] matches_regex "server1.com" } {         
            Replace the Host: header with the new name        
           HTTP::header replace "host" "testserver.de"        
             
            You could also modify the uri with HTTP::uri "new uri"        
             
            a.b.c.d is the IP address of testserver.de        
           use node a.b.c.d 80        
        }        
     }

If you do need to use the DNS name, then you will want to look at the following post:

Click here for link

Thanks for your help!

It works fine, the final irule:

when HTTP_REQUEST {  
    set uri [HTTP::uri]  
    set new_host testserver.de  
    set new_url $new_host$uri  
    if { [HTTP::host] matches_regex "server1.com" } { 
       HTTP::uri http://$new_url  
    }  
 }

---------------------------------------------------------

Cheers