Forum Discussion

Sams_88783's avatar
Sams_88783
Icon for Nimbostratus rankNimbostratus
Dec 01, 2010

Irule Help

We have a site hosted in our webspere server which requires a http redirect.so i have created a irule with

 

 

when HTTP_REQUEST {

 

 

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

 

 

}

 

 

This left the WebSphere port in the redirect, how to remove the port ?

 

Please help with this.

 

 

Thanks

 

3 Replies

  • Hi Sams,

     

     

    Here are a couple of Codeshare examples which should be relevant:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/HTTPToHTTPSRedirect_301.html

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/RewriteHTTPRedirectPort.html

     

     

    Aaron
  • Aaron correct me if i am worng so the irule will be as below correct ? my concern is to remove webspere port because code can add the WebSphere port at any time.

     

     

     

    when HTTP_REQUEST {

     

     

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

     

     

    }

     

     

    when HTTP_RESPONSE {

     

     

    if { [HTTP::header is_redirect]} {

     

     

    HTTP::header replace Location [string map ":[TCP::remote_port]/ /" [HTTP::header value Location]]

     

    }

     

    }

     

  • If I understand your scenario correctly, that's close. You just need to strip out the port on requests:

     

     

    
    when HTTP_REQUEST {
    
        Remove the port from the host header if present and send a redirect to the same URI
       HTTP::redirect "http://[getfield [HTTP::host] : 1][HTTP::uri]"
    }
    
    when HTTP_RESPONSE {
    
        Check if response is a redirect baseed on status code
       if { [HTTP::header is_redirect]} {
    
           Update the location header by removing the pool member's port
          HTTP::header replace Location [string map ":[TCP::server_port]/ /" [HTTP::header value Location]]
       }
    }
    

     

     

    Aaron