Forum Discussion

Tom_Kilday_9259's avatar
Tom_Kilday_9259
Icon for Nimbostratus rankNimbostratus
Oct 16, 2008

how to remove port in http request

How do I remove a port within an http request using an iRule? I want to remove port 80 fromtis request

 

I want change this

 

https://140.247.200.245:80/xythoswfs/

 

to this

 

https://140.247.200.245/xythoswfs/

 

 

Thanks

 

-Tom

 

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi Tom,

    Something like this should work:

     
     when HTTP_REQUEST { 
      
        log local0. "[IP::client_addr]:[TCP::client_port]: New request to [HTTP::host], [HTTP::uri]" 
      
         Check if the host contains a colon 
        if {[HTTP::host] contains ":"}{ 
      
            Replace the Host header with the first field, split on the : 
           HTTP::header replace Host [getfield [HTTP::host] ":" 1] 
      
           log local0. "[IP::client_addr]:[TCP::client_port]: Updating host to [getfield [HTTP::host] ":" 1]" 
        } 
     } 
     

    Aaron