Forum Discussion

kiamars_51328's avatar
kiamars_51328
Icon for Nimbostratus rankNimbostratus
May 18, 2009

How can I get rid of the port on redirects.

Hi, I can redirect to new port, but how can i elemenated the port, I don't want to see the port that I am redirecting.

 

 

thx for your time.

 

 

10 Replies

  • Take a look at the following. It's not the exact item you are looking for but it's close enough that you can replace the event and make it work.

     

     

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

     

     

    CB

     

  • hi, I am new tp irule, would you give me an exmple,

     

     

    right now here is my config

     

    when HTTP_REQUEST {

     

    log local0. "in HTTP_REQUEST"

     

    if { ([HTTP::host] equals "192.168.15.1")}{

     

    HTTP::redirect "http://192.168.15.1:300/" }

     

    elseif {[HTTP::host] equals "192.168.15.1/"} {

     

    HTTP::redirect "http://192.168.15.1" }

     

    }

     

     

    I want port 300 not show when I am browing to vip, can you tell me

     

     

    how can I do that.

     

     

    thx fo ryour time

     

     

     

  • What port is the virtual server defined on? What port are the pool members defined on? Do the web servers require that the Host header value contain the port number (ie, is the virtual host definition expecting the port to be explicitly listed)?

    LTM will translate the port as long as you leave port translation enabled on the virtual server. If you need to, you can rewrite the host header using HTTP::header replace Host "newhost.example.com". Here is an example:

     
     when HTTP_REQUEST { 
      
         Check if host header does not have port already 
        if {[string length [getfield [HTTP::host] ":" 2]] <= 0}{ 
      
            Append the port to the host header value 
           HTTP::header replace Host "[HTTP::host]:300" 
        } 
     } 
     

    If the application includes the port in redirects, you can remove it using the Codeshare example cmbhatt and I linked to above.

    Aaron
  • Thx for reply, I can strip off the port from browser but I am also trying to send it to another directory or applect on webser how do that using above code that you provide to me.

     

     

    thx for your time.
  • This is a cool rule and works around the issue, but is there a way to fix this on the application server? WAS in our case?
  • @skynard: If I recall this should all be handled correctly by the plugin configuration. Be sure and add a virtual host to the application server for this application, then re-generate your plugin. This (or something very close to it) should do the trick.

     

     

    Good luck!

     

     

    -Matt