Forum Discussion
CSA
Nimbostratus
Jan 17, 2011Simple reverse proxy
Hi,
I'm trying to do something quite easy but I can't make it work.
I have an irule like this:
[...]
elseif {[HTTP::path] starts_with "/admin"} { HTTP::redirect pool preprod_admin_pool }
[...]
My pool has two web servers listening on port 8082, and their document root is "/".
I would like to have "/admin" removed from HTTP:uri on the backend requests (ie client still use myhost.com/admin/)
Can I do this easily ? I had a look to reverseproxy big irule but it looks complicated for what I want to achieve.
Thanks,
15 Replies
- Chris_Miller
Altostratus
Are you trying to redirect the user to the page without /admin (first example below), or simply trying to remove the /admin between the LTM and pool member (second example below)? Also, are you trying to pass the request to a specific pool?HTTP::redirect "http://[HTTP::host]/[string range [HTTP::uri] 6 end]"HTTP::uri /[string range [HTTP::uri] 6 end] - CSA
Nimbostratus
Sorry, it was this :
elseif {[HTTP::path] starts_with "/admin"} { pool preprod_admin_pool }
Before, it worked like this:
- user types http://myapp.domain.com/admin
- he's redirected to http://host.domain.com:8082/ (only member today of preprod_admin_pool)
I would like to have this:
- user types http://myapp.domain.com/admin
- he sees the content of http://host.domain:8082/ while having http://myapp.domain.com/admin/ as a URL basis
Your second example works for the first request, but if I click on a link of the app (pointing for example to http://host.domain.com:8082/directory/, the URL I have in the browser is http://myapp.domain.com/directory/ (instead of /admin/directory, so I get a "file not found")
Thanks - Chris_Miller
Altostratus
Thanks for the explanation.
The second example isn't a redirect so I'm not sure why it would change the browser's request. You mentioned the link points to /directory/...is it coded for that for some reason? - CSA
Nimbostratus
I meant that my application is like a /index.html file in the document root with some
In fact, I found that the problem is absolute links in the application like /directory/foobar.html. I think it would work with relative links. I cannot change absolute links to relative links as I don't control the application - Chris_Miller
Altostratus
So:
1. User requests http://myapp.domain.com/admin/directory.
2. LTM sends their request to pool member as http://myapp.domain.com/directory.
3. If the user requests foobar.html, aren't they doing so as http://myapp.domain.com/admin/directory/foobar.html? In which case their request would be sent to the pool member as http://myapp.domain.com/directory/footbar.html?
I'm not quite getting where the issue is. - CSA
Nimbostratus
1. User requests http://myapp.domain.com/admin/ . It works, he gets let's say "index.html" file (thanks to your tip with HTTP::uri /[string range [HTTP::uri] 6 end]
)
2. User clicks on a link pointing to "/directory/foobar.html"
3. It doesn't work because in the index.html page the user is getting, the link is "/directory/foobar.html". And it should be "/admin/directory/foobar.html" to have it redirected properly I think.
I think I have to rewrite server's response. - Chris_Miller
Altostratus
Posted By CS on 01/17/2011 08:27 AM
1. User requests http://myapp.domain.com/admin/ . It works, he gets let's say "index.html" file (thanks to your tip with HTTP::uri /[string range [HTTP::uri] 6 end]
)
2. User clicks on a link pointing to "/directory/foobar.html"
3. It doesn't work because in the index.html page the user is getting, the link is "/directory/foobar.html". And it should be "/admin/directory/foobar.html" to have it redirected properly I think.
I think I have to rewrite server's response.
It sounds like index.html is using relative links then, no? If the user gets a 404 for /directory/foobar.html, why are we trying to remove the /admin from the request? - CSA
Nimbostratus
no, index.html is using absolute links : - CSA
Nimbostratus
raah "quick reply" cut my answer !! - CSA
Nimbostratus
No, index.html uses absolute links : for example, . I mean by absolute links, links absolute relative to the document root, not to the filesystem.
myapp.domain.com points to the "business" application on a certain pool. Adding /admin should point to another pool hosting the admin application. The admin application itself doesn't have /admin, that's why we need to keep the /admin on the client side and remove it on the server side.
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
