Forum Discussion

Pramod_Gopala_1's avatar
Pramod_Gopala_1
Icon for Nimbostratus rankNimbostratus
Oct 15, 2015

Adding Port translation from 8080 to 80 in the existing iRule.

Hi All,

 

Need an help to refine the existing iRule for a port translation.

 

when HTTP_REQUEST {
log local0. "Request HOST is [HTTP::host] URI is [HTTP::uri]"
if {[string tolower [HTTP::host]] starts_with "www.mywebsite.com"}
{
switch -glob [string tolower [HTTP::uri]] {
"/seatrans*" { pool Sea_trans }
"/emarine*" { pool Emarine }
"/intranet/*" { pool intranet }
"/pts*" { pool PTS } 
"/foundry*" { pool ifoundry }
                "/omni*" { pool Omnidocs }
"/engg*" { pool Eproperty }
                "/codes*" { pool CODESK }
"/ipcm*" { pool RSA-iPLCMS-HTTPS }
"/*" { pool HTTP-www.mywebsite.com }
    }
}

In the above code only /seatrans page once it is accessed and filled its form data and submitted by clicking Submit button, the data will be carried with the following URL http://www.mywebsite.com:8080/setrans/GetTransValues.asmx will be returned to F5 from the client. Now how to convert the port in the header from 8080 to 80 before sending it to the pool member? Is that can be achieved with iRule or any other options available.

 

Please let me know. Thank you in advance!

 

1 Reply

  • You can do a string map:

    when HTTP_REQUEST {
        HTTP::header replace Host [string map {":8080" ""} [HTTP::header Host]]
    }
    

    Since you're changing it to 80 (a standard HTTP port), you probably don't need to send it to the server, so I'm just removing :8080 from the Host header.