Forum Discussion
jgrohol_43248
Nimbostratus
Jun 28, 2010Port Translation
I've been struggling all day with this one... I have two separate problems and not sure if they are related.
1. I have a VS configured to listen on an IP and on port HTTP 80. I have it attached to a pool with a few webservers in it. The webservers are serving on port TCP 8080 instead. I have the "Port Translation" checkbox checked under the VS settings. It appears that it is not working.
2. The URL that points to that VIP is "http://test1.phly.net". When you hit that URL and it gets passed along to the pool member, the server replies with an HTTP 301 redirect and replies with its own hostname instead "http://server1.phly.net". We want to find when a 301 redirect comes in and replace the hostname with the original URL of "http://test1.phly.net". I've been working with iRules but couldn't really get anything working as of yet. One of the problems in the iRule is that we don't want to statically set what to swap out in the HTTP Header. This needs to be dynamic because of all of the possible pool members that it can have.
Any ideas or suggestions?
I'm on version 10.1.0.
- Michael_Yates
Nimbostratus
You will need to find what is sending the 301 Redirect (sounds like the server(s)) and stop it there.when HTTP_RESPONSE { if { [HTTP::is_redirect] } { HTTP::header replace Location [ string map {"server1" "test1"} [HTTP::header Location] ] } }
- hoolio
Cirrostratus
Port translation is fairly bullet proof. I'd guess the issue is not with the port translation, but with the application's references to itself within the HTTP.when HTTP_RESPONSE { Check if response is a redirect if {[HTTP::is_redirect]}{ Replace the hostname in the Location header with the external FQDN HTTP::header replace Location "[string map -nocase [URI::host [HTTP::header Location]] test1.phly.net" [HTTP::header Location]] } }
- jgrohol_43248
Nimbostratus
Michael I was using that same iRule to test, the only problem is I'd have to statically define the server hostnames to replace. I want to keep that part dynamic so I don't have to update the iRule everytime they add a server to the pool. - hoolio
Cirrostratus
Sorry, it was a misplaced double quote. Can you try this:when HTTP_RESPONSE { Check if response is a redirect if {[HTTP::is_redirect]}{ Replace the hostname in the Location header with the external FQDN HTTP::header replace Location [string map -nocase "[URI::host [HTTP::header Location]] test1.phly.net" [HTTP::header Location]] } }
- jgrohol_43248
Nimbostratus
That worked...when HTTP_REQUEST { set ext_fqdn "[HTTP::host]" } when HTTP_RESPONSE { Check if response is a redirect if {[HTTP::is_redirect]}{ Replace the hostname in the Location header with the external FQDN HTTP::header replace Location [string map -nocase "[URI::host [HTTP::header Location]] $ext_fqdn" [HTTP::header Location]] } }
- jgrohol_43248
Nimbostratus
I also had a question... Isn't this iRule the same thing as changing the "Redirect Rewrite" under the Profile? - hoolio
Cirrostratus
Nice work. - jgrohol_43248
Nimbostratus
Ok. Thanks for that explanation. - hoolio
Cirrostratus
Do you see any errors in /var/log/ltm when testing with IE or Chrome? Can you use a browser plugin like Fiddler to see which request the failure is occurring on? - jgrohol_43248
Nimbostratus
Well here's the crazy part. In the end they want to replace the hostname in the redirect to keep the common URI. They also want the VIP to be on port HTTP 80 while the backend pool servers are on port 8080. I just changed my VS to listen on 80 instead of 8080 and wham. All 3 browsers now work with the port translation and the hostname change in the iRule we made. Weird. Not sure why doing the port translation "fixed" the other browser problems.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects