Forum Discussion
Francois_Begin_
Nimbostratus
Jul 06, 2005Redirect questions
Hi all,
I am trying to create a re-direct that will achieve this:
Take a request for http://banana.fruits.com/Data and re-direct it to http://:1601/
At this time, we re-direct to a single server, but we will be re-directing to a pool of servers in the future.
The request comes in on port 80 and goes to port 1601 on the back end server.
The '/Data' of the initial request needs to be stripped. The html documents being accessed are located at the root of the back end server.
So far, I made it work with this simple irule:
when HTTP_REQUEST {
if { [HTTP::uri] contains "ASFData" } {
HTTP::redirect http://142.178.100.139:1601
}
}
This works but there are a few problems:
Firstly, this works only for a single host. How would I re-direct to multiple hosts? And how would I ensure availability if one of the hosts was to go down?
Secondly, when a user type in http://banana.fruits.com/Data in his/her browser, this gets changed to http://:1601. Can I do this re-direct transparently for the user i.e. he/she would still see http://banana.fruits.com/Data in his/her browser but get re-directed to the back end server.
Thanks,
François Bégin
9 Replies
- drteeth_127330Historic F5 AccountDo you need to use a redirect? Why not select a different pool instead?
- François_Bégin_
Nimbostratus
I tried selecting a pool but that did not work as I need to deal with '/Data'. Selecting a pool means the request goes from
http://banana.fruits.com/Data
to
http:///Data
If I could truncate '/Data', then that would work.
François - drteeth_127330Historic F5 AccountYes, you can rewrite the request. If there are no path components following data, then something like this should work:
HTTP::request "/"
If there are path components following data, then you will have to perform some string manipulation to preserve them. - François_Bégin_
Nimbostratus
Ok, here is the irule I am trying to enter:
when HTTP_REQUEST {
if { [HTTP::uri] contains "Data" } {
HTTP::request "/"
use pool backend_servers
}
}
But for some reason, the F5 is not allowing me to enter that rule. I get the following error:
01070151:3: Rule [asfdata_redirect_tmp] error:
line 3: [undefined procedure: HTTP::request] [HTTP::request]
This F5 is running BIG-IP 9.0.4 Build 118.5
François - drteeth_127330Historic F5 AccountOops. I meant HTTP::uri. Sorry.
- François_Bégin_
Nimbostratus
Still no success. Here is my rule
when HTTP_REQUEST {
if { [HTTP::uri] contains "Data" } {
HTTP::uri "/"
use pool backend_servers
}
}
I added a few log directives to track down what was happening. I see the request coming in for http://banana.fruits.com/Data and HTTP:uri is initially set to '/Data'. The log does not indicate that HTTP::uri gets changed to "/" and snooping on the back end server shows no http traffic hitting the server.
Francois - drteeth_127330Historic F5 AccountDid you add the log directives in the iRule or on the back-end webserver? I have tested the rule on my big-ip and it appears to work as intended. What version of big-ip are you running? I seem to recall a bug with the contains operator, but it was fixed long ago.
- François_Bégin_
Nimbostratus
Log directives were on the F5
when HTTP_REQUEST {
if { [HTTP::uri] contains "Data" } {
log "I received a request for Data"
log [HTTP::uri]
HTTP::uri "/"
log [HTTP::uri]
pool app_asfdata_dvlog
}
}
All I see in the logs is
I received a request for Data
/Data
I was expecting to see
I received a request for Data
/Data
/
Running BIG-IP 9.0.4 Build 118.5 - François_Bégin_
Nimbostratus
This appears to be working now. I was missing a default SNAT, and a default pool for the irule.
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
