Forum Discussion

Rav_99576's avatar
Rav_99576
Icon for Nimbostratus rankNimbostratus
Feb 05, 2012

Redirect Port

Hello Everybody,

 

 

I have a case over here that i need to redirect the port that hits my VIP meaning

 

 

I have already a Service running on port 80 and all the requests that i receive are going through this port while the back end servers have the port 7778 running on.

 

 

So all i need is when i receive any request on port 7778 to be redirected to port 80

 

 

Http://10.10.10.1:7778/index.htm > http://10.10.10.1/index.htm

 

 

What i thought of is this but it didnt work i might need your help folks :

 

 

when HTTP_REQUEST {

 

if {[TCP::client_port] != "80"}{

 

HTTP::redirect "http://10.10.10.1[HTTP::uri]"

 

}

 

}

 

 

Thnx in advance

 

8 Replies

  • can you try this?

    [root@ve1023:Active] config  b virtual list
    virtual bar {
       destination 172.28.19.79:any
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    virtual bar80 {
       snat automap
       pool foo
       destination 172.28.19.79:80
       ip protocol 6
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
            HTTP::redirect "http://[getfield [HTTP::host] ":" 1][HTTP::uri]"
    }
    }
    
    [root@ve1023:Active] config  curl -I http://172.28.19.79:8080/test
    HTTP/1.0 302 Found
    Location: http://172.28.19.79/test
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    
  • i tried this rule before but always shows :

     

     

    The page isn't redirecting properly

     

     

    and the curl -I http://10.10.10.1:7778/index.htm doesnt come with output

     

     

    i need to find the port it self in the Host like HTTP::host contains "7778" or ":" but it doesnt catch it

     

     

    any idea ?
  • this is mine.

    [root@ve1023:Active] config  curl -IL http://172.28.19.79:7778/
    HTTP/1.0 302 Found
    Location: http://172.28.19.79/
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    HTTP/1.1 200 OK
    Date: Sun, 05 Feb 2012 09:47:48 GMT
    Server: Apache/2.2.3 (CentOS)
    Last-Modified: Fri, 11 Nov 2011 14:48:14 GMT
    ETag: "4183e4-3e-9c564780"
    Accept-Ranges: bytes
    Content-Length: 62
    Content-Type: text/html; charset=UTF-8
    
    

    can you post your virtual server configuration?

    b virtual virtual-server-name list
  • i just noticed you are using TCP::client_port. it shoud be TCP::local_port.
  • virtual WebACM {

     

    snat automap

     

    pool tbs-servers

     

    destination 10.10.10.1:http

     

    ip protocol tcp

     

    vlans Zajil-VLAN enable

     

    rules PortDest

     

    httpclass httpclass

     

    profiles

     

    http-acceleration

     

    tcp

     

    persist TBS-accelerator

     

    }

     

     

     

    i also tried TCP::local_port it didnt work

     

  • when browsing http://10.10.10.1:7778/, it won't hit your virtual server since it is listening on port 80. you have to create another wildcard port virtual server something like the one i posted above or use only one virtual server like the following.

    [root@ve1023:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.79:any
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve1023:Active] config  b pool foo list
    bpool foo {
       members 200.200.200.101:80 {}
    }
    [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
            if {[TCP::local_port] != 80}{
                    HTTP::redirect "http://[getfield [HTTP::host] ":" 1][HTTP::uri]"
            }
    }
    }
    
    [root@ve1023:Active] config  curl -IL http://172.28.19.79:7778/
    HTTP/1.0 302 Found
    Location: http://172.28.19.79/
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    HTTP/1.1 200 OK
    Date: Sun, 05 Feb 2012 09:53:23 GMT
    Server: Apache/2.2.3 (CentOS)
    Last-Modified: Fri, 11 Nov 2011 14:48:14 GMT
    ETag: "4183e4-3e-9c564780"
    Accept-Ranges: bytes
    Content-Length: 62
    Content-Type: text/html; charset=UTF-8
    
    
  • Thnx dude it works like a charm XD !! actually i havent thought of it not reaching the VIP itself ... seriously i dunno how did i miss it :P

     

     

    Anyway thanks alot !!