Forum Discussion
Emre_27149
Nimbostratus
May 09, 2011irule redirection issue
Hi,
Incoming client requests to http://xyz.com.tr - (10.x.x.199) distrubutes to the pool httpgw-8086-pool but I want to change the URI when the clinet requests load balanced (exmp: 10.x.x.257:8086/httpgw) . I have wrote the below irules to accomplish my goal but it did not work.How can I direct the client requests to the pool as . Thank you."
pool httpgw-8086-pool {
monitor all tcp
members {
10.x.x.157:8086 {}
10.x.x.158:8086 {
session user disabled
}
}
rule httpgw-irule {
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] equals "/" } {
HTTP::uri [string map -nocase {"/" "/httpgw"} [HTTP::uri]]
}
}
}
rule httpgw-irule-alternate {
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" }
{ set newuri "/httpgw"
log "Incoming uri - [HTTP::uri] being translated to $newuri"
HTTP::uri $newuri
}
}
}
rule httpgw-redirection {
when HTTP_REQUEST {
if { (([HTTP::host] equals "xyz.com.tr") and ([HTTP::uri] equals "/")) }{
HTTP::redirect "http://xyz.com.tr/httpgw"
}
}
}
virtual httpgw-8086-VIP {
pool httpgw-8086-pool
destination 10.x.x.199:http
ip protocol tcp
rules httpgw-irule-alternate
persist source_addr
profiles {
http {}
tcp-lan-optimized {
clientside
} tcp-wan-optimized {
serverside
}
}
}
8 Replies
- Michael_Yates
Nimbostratus
The iRule that you have written will mask the URI to the user and send the modified URI to the server.
If you want the User to see the redirect you can modify your iRule slightly.when HTTP_REQUEST { if { [HTTP::uri] equals "/" } { set newuri "/httpgw" log "Incoming uri - [HTTP::uri] being translated to $newuri" HTTP::uri $newuri HTTP::redirect $newuri } }
Hope this helps, but if this is not the behavior that you are looking for let me know. - Emre_27149
Nimbostratus
Hi Michael,
Thank you for your helps.It is working as well.Your rule is changing incoming request to xyz.com.tr/httpgw and redirecting to pool members. If this possible I also want to know that how can I redirect incoming request to pool members as :port/httpgw .
Regards, - Michael_Yates
Nimbostratus
You can specify a specific Node and Port with the node command.
http://devcentral.f5.com/Wiki/default.aspx/iRules.node
I don't think that is what you are trying to do though. Are you trying to work around default Virtual Server Address and Port Translations?
Address Translation
Specifies, when checked (enabled), that the system translates the address of the virtual server. When cleared (disabled), specifies that the system uses the address without translation. This option is useful when the system is load balancing devices that have the same IP address. The default is enabled.
Port Translation
Specifies, when checked (enabled), that the system translates the port of the virtual server. When cleared (disabled), specifies that the system uses the port without translation. Turning off port translation for a virtual server is useful if you want to use the virtual server to load balance connections to any service. The default is enabled.
You can de-select these options on the Virtual Server and see if that gives you the behavior that you are looking for. - Emre_27149
Nimbostratus
Hi Michael,
The client request need to go pool member as :port/httpgw . is that possible?
Regards - Emre_27149
Nimbostratus
Hi Micheal
You rule is changing the client uri as xyz.com.tr/httpgw and redirecting it to pool members.But I want to do that the requests go to pool member as : port/httpgw . - Michael_Yates
Nimbostratus
Yes I believe that you can, but you would need to further refine the iRule and build the destination in the HTTP::redirect event.
You should be able to get the Destination Server and Port from the LB::server Command.
Look here for ideas: http://devcentral.f5.com/wiki/default.aspx/iRules/LB__server.html - Emre_27149
Nimbostratus
Hi Michael,
That will be good article to accomplish my goal.Thank you for your helps, - hoolio
Cirrostratus
If you want to rewrite the host header based on the selected pool member IP and/or port, you can use the HTTP_REQUEST_SEND event. Here is a 9.4.x example which you could modify to use the class command for 10.x:
http://devcentral.f5.com/wiki/default.aspx/iRules/rewrite_host_header_to_server_name.html
http://devcentral.f5.com/wiki/default.aspx/iRules/class
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
