Forum Discussion
URL hostname rewrite
Got a question from one of my application owners in regards to Remedy (BMC Software). They're looking to have the LTM do the following:
-
User types in URL http://support.mycompany.com
-
Traffic gets load balanced to a server in the pool, in this example server1
Is it possible to have the URL modified to show http://server1.mycompany.com instead of http://support.mycompany.com
Any help would be greatly appreciated - thanks!!
4 Replies
Sure can. If you just want to change the host header sent to your backend server while maintaing the support.mycompany.com to your end users, just use the HTTP::header command to change the host header. Something like this should work
when HTTP_REQUEST { if { [HTTP::host] eq "support.mycompany.com" } { HTTP::header replace "Host" "server1.mycompany.com" } }
The "if" check on the host is only in case you are multi-hosting this iRule. If you want to unconditionally change the host value sent back to the server, you can just use the HTTP::header replace command by itself.
Keep in mind though that if you pass a host value to the back end app server, that some app servers may generate page links based on the passed in host header. If your app did this, you'd have to have a DNS entry for server1.mycompany.com that goes to your VIP.
If you want to do a redirect (which is not what it sounds like you want, you can do a simple redirect
when HTTP_REQUEST { if { [HTTP::host] eq "support.mycompany.com" } { HTTP::redirect "http://server1.mycompany.com[HTTP::uri]" } }
Hope this helps...
-Joe
- Kevin_Stewart
Employee
You should just need to change the Host header in the request. Example:
when HTTP_REQUEST { HTTP::header replace Host "server1.mycompany.com" }
- Pete_Paiva_7147
Nimbostratus
Guys, this is great thanks for the quick reply!!
In this case we have 8 servers in the pool so how can I create the iRule so it works depending on the specific pool member?
- Kevin_Stewart
Employee
Two options:
-
You could maintain a data group that maps the name to the IP. Example:
datagroup (ex. my_server_dg): 10.10.42.10 := server1.domain.com 10.10.42.11 := server2.domain.com 10.10.42.12 := server3.domain.com iRule: when HTTP_REQUEST_SEND { clientside { HTTP::header replace "Host" [class match -value [LB::server addr] equals my_server_dg] } }
-
If you have internal DNS you could do a quick reverse lookup to get the name.
-
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