Forum Discussion
Change http host and path (reverse proxy) without redirecting the client
Hi Guys,
There is a business need where our clients will go to http://www.abc.com/app-a/index.php. I want my f5 to forward that request to http://www.xyz.com/app-xyz/some-more/index.php
I do not want the clients to see this in their browser hence want to simulate reverse proxy. I tried this,
when HTTP_REQUEST {
if { [string tolower [HTTP::path]] equals "/app-a/index.php" } {
HTTP::path /app-xyz/some-more/index.php
HTTP::header replace Host "www.xyz.com"
}
}
But this isn't working. I know how redirect works and I could do that with this case but unfortunately that isn't an option.
Appreciate your help.
Anuj
3 Replies
- What_Lies_Bene1
Cirrostratus
I think you've missed quotation marks around the new path. I've added some logging too;when HTTP_REQUEST { if { [string tolower [HTTP::path]] equals "/app-a/index.php" } { log local0. "Matched HTTP path of /app-a/index.php" HTTP::path "/app-xyz/some-more/index.php" log local0. "Replaced path" HTTP::header replace Host "www.xyz.com" log local0. "Replaced host" } } - anuj_2931
Nimbostratus
Hi Steve,
Thanks for your response. Our irule is mostly similar minus the logging. I still replaced it with yours. The pool which is part of the Virtual server doesnt serve this the new url or www.xyz.com.
I thought F5 will forward the request after looking up DNS. Which I now know will not work.
So after this irule before closing the IF Condition. I added the statement
pool XYZ-COM-POOL
and also tried
node 192.168.10.x 80
where 10,x node has apache which servers www.xyz.com. I still don't see F5 hitting the node or the pool for www.xyz.com/. What am I doing wrong here.
Thanks,
Anuj - What_Lies_Bene1
Cirrostratus
OK. I don't see why the pool or node commands wouldn't work.
1) Do you see log entries to show the path is being matched?
2) The new iRule code won't apply to existing or persisted connections. Fully close whatever browser client you're using to test and test again.
3) Are you 100% sure all subsequent requests will have the same path?
4) If none of the above help, it'll be tcpdump time!
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