Forum Discussion
Forward to specific pool and remove URL's path
I am really stuck and can't figure what's wrong and need help. BTW, I am a newbie.
Rewrite to URL and strip part of the URI
Example 1) URL https://www.xyz.com/index1.html default POOL1 2) URL https://www.xyz.com/ping so when someone enter 2, it would forward to POOL2 and remove the "/ping path" to just only https://www.xyz.com
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/ping" } { HTTP::path [string range [HTTP::path] 0 3] pool POOL2 } else { pool POOL1 } }
9 Replies
- Kevin_Davies_40
Nacreous
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/ping" } { HTTP::path "/" pool POOL2 } else { pool POOL1 } }- Peter_125758
Nimbostratus
Thank you very much. It actually forward to the pool2 when the initial input has a /ping path. However, the /ping path is still not removed permanently. So, how do you remove the path "/ping" permanently?
- Kevin_Davies_40
Nacreous
The /ping path is removed from the traffic passing to the pool you just don't see that in the browser. If you want it in the browser then you have to use HTTP::redirect "/". However then your request will go to POOL1 everytime as you will make a new request with "/".
- Peter_125758
Nimbostratus
Hi Kevin,
Thank you very much for your prompt reply. I did exactly as you suggested, and got the POOL2 page, but when I start browsing the page, I got 404 error. Guess, I need to do more researches.
Thank you very much, -Peter
- Kevin_Davies_40
Nacreous
Ahh so /ping is not a one off page. You want to browse a site from that pool, ok then we need to adjust your iRule.
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/ping" } { HTTP::path "/[string range 6 end]" pool POOL2 } else { pool POOL1 } } - Peter_125758
Nimbostratus
Thank you very much, I still got a 404 error when browse the pool. I mean once the forward to POOL2, user should be able to browse everything in POOL2 per your advice. I wonder if the version 11.3 has a bug w/ iRule.
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/ping" } { HTTP::path "/[string range 0 6 end]" pool POOL2 } else { pool POOL1 } }
- Kevin_Davies_40
Nacreous
Add a log command after pool2
log local0. [HTTP::uri]
Paste the output below
- nitass
Employee
I still got a 404 error when browse the pool. I mean once the forward to POOL2, user should be able to browse everything in POOL2 per your advice. I wonder if the version 11.3 has a bug w/ iRule.
i do not think it is a bug. i think it is about how uri is organized.
have you ever used http analyzer tool such as httpfox? it may be helpful.
HttpFox
https://addons.mozilla.org/en-US/firefox/addon/httpfox/ - Kevin_Davies_40
Nacreous
The issue here is we do not have enough detail on what you want to achieve. When you make a request using /ping, are you expecting all the subsequent requests to now come from pool2? If so you need to add persistence in addition to the iRule. Start with adding source address persistence and see if that resolves your issue.
Here is a logging iRule you can use to track what is going on. Paste the logs to gist.github.com and drop a link here.
when CLIENT_CONNECTED { set cid [clock clicks] log local0. "\[$cid\] Client Connected XXXX" } when HTTP_REQUEST { set rid [clock clicks] log local0. "\[$rid\] HTTP Request for [HTTP::uri] XXXX" }From the command line your BIGIP then use the following commands to get your logs
tail -f /var/log/ltm | grep XXXX
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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