Forum Discussion
Simple HTTP session termination then back end session to web server
Hello Gurus! I'm VERY new to LTM but I suspect this one will be simple.
I've got an internal web app that simply uses http on port 80 from a company we acquired, which is currently on their local AD domain. We'll call it http://currenturl.olddomain.local/webapp.
In order to get our users that come in over our global WAN into a higher queue in QOS I need them to make connections on a custom port (8052), but we don't want to change the web server. So, I want provide the users across the pond a totally different URL that terminates at the F5 on http port 8052 (http://newurl.ourdomain.com:8052/) and then have the F5 proxy the session to the web server by opening a new connection on the back end to the web server on the actual URL (http://currenturl.olddomain.local/webapp).
Any help or article references would be much appreciated!
- Kevin_StewartEmployee
This will probably require a STREAM expression. Enable an empty STREAM profile on the VIP and add this code:
when HTTP_REQUEST { STREAM::disable HTTP::header remove "Accept-Encoding" } when HTTP_RESPONSE { if {[HTTP::header value Content-Type] contains "text"}{ STREAM::expression {@currenturl.olddomain.local@newurl.ourdomain.com:8052@} STREAM::enable } }
- Mark_VogelAltostratus
Thanks Kevin. How do I tie that into the original iRule below?
when HTTP_REQUEST { HTTP::header replace Host "currenturl.olddomain.local" }
- Kevin_StewartEmployee
This should work:
when HTTP_REQUEST { STREAM::disable HTTP::header remove "Accept-Encoding" if { [TCP::local_port] equals "8052" } { if { [HTTP::uri] equals "/" } { HTTP::redirect "http://[HTTP::host]/webapp" } else { HTTP::header replace Host "currenturl.olddomain.local" } } } when HTTP_RESPONSE { if {[HTTP::header value Content-Type] contains "text"}{ STREAM::expression {@currenturl.olddomain.local@newurl.ourdomain.com:8052@} STREAM::enable } }
- Mark_VogelAltostratus
Looks like still the same result with that in place. Same thing shown by ieHTTPHeaders also. I just used the built in default stream profile which has nothing in it.
As a side note, doesn't look like the if statement for the / and the /webapp is needed. Also, unless the "if" statement to check for 8052 is needed for some following code to execute, we can probably get rid of that as well since all connections coming to this VS will be on 8052 only.
- Kevin_StewartEmployee
Are you still seeing this in the response?
HTTP/1.1 301 Moved Permanently Content-Type: text/html; charset=UTF-8 Location: http://currenturl.olddomain.local/scan/ Server: Microsoft-IIS/7.5 X-Powered-By: ASP.NET Date: Thu, 17 Oct 2013 15:57:09 GMT Content-Length: 150
You could probably also get rid of the Host header replacement. Not many web servers actually need that.
- Mark_VogelAltostratus
Yep, same as before:
HTTP/1.1 301 Moved Permanently Content-Type: text/html; charset=UTF-8 Location: http://currenturl.olddomain.local/scan/ Server: Microsoft-IIS/7.5 X-Powered-By: ASP.NET Date: Thu, 17 Oct 2013 18:31:37 GMT Transfer-Encoding: chunked
I need the host header though so F5 creates its connection to the old URL that's still used on the server, right?
- Kevin_StewartEmployee
Right... The STREAM profile won't catch response headers in the HTTP_RESPONSE event. Since we're just looking for a redirect, try this instead:
when HTTP_RESPONSE { if { [HTTP::is_redirect] } { HTTP::header replace Location [string map {"currenturl.olddomain.local" "newurl.ourdomain.com:8052"} [HTTP::header Location]] } }
- Mark_VogelAltostratus
YOU DA MAN!! That did it!
Alright, now for what should be the last bit of trickery...
Like I mentioned, there are four different URIs that can be specified for the URL. They're all working properly with the way the iRule is written now but the name of one of them is undesirable (political thing....). So using the /webapp as an expample, we'd like users to enter /app when entering the new URL (instead of /webapp), but I need the F5 to send that to /webapp when it makes its connection. So, when user enters http://newurl.ourdomain.com:8052/app, the F5 should open its connection to http://currenturl.olddomain.local/webapp. All other /.... should be left alone.
- Kevin_StewartEmployee
Ahh... you're about to venture into the world of ProxyPass, or if on 11.4, policy rules. Both will perform the translation from external URI patterns to internal URI patterns, and back.
- Mark_VogelAltostratus
Can we just slip an if/then into the current iRule that says IF the client specifies http://newurl.ourdomain.com:8052/app THEN on the back end make it http://currenturl.olddomain.local/webapp? Then if they specify /anythingelse it will just pass through and only change the host header domain name? Or will things get screwed up because even more pops in after /webapp?
We're on 10.2.1 btw.
Recent Discussions
Related Content
* 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