Forum Discussion
thethe94_91706
Nimbostratus
May 10, 2011redirect and rewriting
how i can erase this post ?
14 Replies
- hoolio
Cirrostratus
Here are a few examples of rewriting the hostname in redirects:
http://devcentral.f5.com/wiki/default.aspx/iRules/RewriteHTTPRedirectHostname.html
If you get stuck, try using a browser plugin like Fiddler and/or debug logging in the iRule to trace what's happening versus what you want to happen.
Aaron - thethe94_91706
Nimbostratus
. - hoolio
Cirrostratus
That's not much to work with in terms of a problem statement.
What iRule code did you try? What debug logging did you add? What testing did you do? Were you able to install Fiddler and reproduce the issue?
Aaron - thethe94_91706
Nimbostratus
. - hoolio
Cirrostratus
If you want to hide the rewriting of the Host header from the client, you'd want to use:
HTTP::header replace Host "testctv-intra"
Note that the Host header must not contain the protocol or any part of the URI.
Using HTTP::redirect will trigger LTM sending a 302 redirect to the new location. The change will be displayed in the address bar on the browser.
Do you want to rewrite any request which contains urba so that the host is testctv-intra? When do you want to rewrite the URI to /wiki? Only when the client requests /urba?
Aaron - thethe94_91706
Nimbostratus
. - hoolio
Cirrostratus
Can you try this to start with? I assume it won't work completely, but will give you something to test. If it doesn't work, can you check the /var/log/ltm log file for the output? You can use 'tail -f /var/log/ltm' from the command line to watch the log as it's written to.when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to host [HTTP::host] and URI [HTTP::uri]" Check if the Host is testctv-intra and the URI is /urba if { [string tolower [HTTP::host]] eq "testctv-intra" and [HTTP::path] eq "/urba"} { Rewrite the Host header to lurba001 HTTP::header replace Host "lurba001" Rewrite the URI to /wiki HTTP::uri "/wiki" log local0. "[IP::client_addr]:[TCP::client_port]: Rewriting host from testctv-intra to lurba001 and URI from /urba to /wiki" } } when HTTP_RESPONSE { This event is here for debug logging only if {[HTTP::is_redirect]}{ log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::status] redirect response with Location [HTTP::header Location]" } else { log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::status] response" } }
Aaron - thethe94_91706
Nimbostratus
. - hoolio
Cirrostratus
Yep, so that's why I was rewriting the Host and URI before the request is sent to the pool versus sending a redirect to the client. Have you tried the last iRule I posted? If you did and it didn't work, can you check the logs in /var/log/ltm and reply with details on what didn't work using Fiddler to determine it?
Aaron - thethe94_91706
Nimbostratus
.
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
