Forum Discussion

meena_60183's avatar
meena_60183
Icon for Nimbostratus rankNimbostratus
Feb 07, 2008

Hide port numbers on the URL

I need some help in configuring an iRule to hide a port number on the URL. I am very new to the F5 world.

 

 

I have a URL

 

 

http://10.35.253.131:8080

 

 

and I need to redirect them to https://10.35.253.131:8081 and I did that with a profile. Now, they do not want the port number 8081 to show up on the URL. How can I do that?

 

 

I am just getting confused between iRule and profile and not sure when to use what.

 

 

thanks,

 

1 Reply

  • You should be able to define the VIP on the port you want clients to make requests to and the pool members on whatever port the web server listens on. Just make sure port translation is enabled on the VIP (which it is by default).

    If the web servers send redirects with the wrong port in the Location field, you can use an iRule to replace that with the VIP's IP/port:

    
    when HTTP_RESPONSE {
       if { [HTTP::status] starts_with "3" } {
          HTTP::header replace Location [string map -nocase {myold.hostname.com:8081 mynew.hostname.com:8080} [HTTP::header Location]]
      }
    }

    Or you can try using the rewrite redirects option on the HTTP profile. Check these related solutions on AskF5 for details/known issues (Click here and Click here).

    If the servers include absolute references to the incorrect IP and/or port in response content (the html), check the last example on the STREAM::expression wiki page (Click here) for details on how to perform the replacement in content as well.

    Aaron