Forum Discussion
Andi_102219
Nimbostratus
Oct 21, 2010ProxyPass issues
I'm using LTM v9.3 and want to redirect requests to a certain URL with the ProxyPass iRule.
iRule is assinged to my virtual server(s) and created the needed data group(s).
I guess I'm having problems to exactly understand how it works. Therefore I enabled the logging to see what's going on.
Rule ProxyPass : , Host=, URI=/test: Found Rule, Client Host=, Client Path=/test, Server Host=, Server Path=/php/telefonauskunft
Rule ProxyPass : , Host=, URI=/test: Redirecting to http:///test/
So the issue is simply described. I want to redirect from "requested-host" to the recognized server host ("other-host"). But when I try it just redirects me to the original requested host.
Strange...
What's wrong / Where is my missunderstanding?
6 Replies
- Derek_Murphy_38
Nimbostratus
Hi Andi,
I recently needed to figure out how to use the proxypass iRule and had quite a struggle getting it to work right.
Below is a post based on my experience... I said I was going to summarize everything I found... but didn't get a chance to yet. See if the below helps.. now that I'm thinking about it, I'll try to summarize tonight.
Cheers,
-Derek
http://devcentral.f5.com/Forums/tabid/1082223/asg/50/showtab/groupforums/afv/topic/aff/5/aft/1174362/Default.aspx - hoolio
Cirrostratus
Hi Andi,
Did you have text between angle brackets in your post? If so, DC misinterprets these and strips the text. Can you repost your log entries and put spaces in the strings like this < my info >?
Thanks, Aaron - Andi_102219
Nimbostratus
@Derek no that didn't really help me :-(
Sorry, here again the log lines from a single request to http://host1.domain.de/test :
< date > Rule ProxyPass < HTTP_REQUEST >: < v-server >, Host=host1.domain.de, URI=/test: Looking for entries matching host1.domain.de/test
< date > Rule ProxyPass < HTTP_REQUEST >: < v-server >, Host=host1.domain.de, URI=/test: Found Rule, Client Host=host1.domain.de, Client Path=/test, Server Host=host2.domain.de, Server Path=/php/somepath/
< date > Rule ProxyPass < HTTP_REQUEST >: < v-server >, Host=host1.domain.de, URI=/test: Redirecting to http://host1.domain.de/test/
< date > Rule ProxyPass < HTTP_REQUEST >: < v-server >, Host=host1.domain.de, URI=/test/: Looking for entries matching host1.domain.de/test/
< date > Rule ProxyPass < HTTP_REQUEST >: < v-server >, Host=host1.domain.de, URI=/test/: Found Rule, Client Host=host1.domain.de, Client Path=/test, Server Host=host2.domain.de, Server Path=/php/somepath
< date > Rule ProxyPass : < v-server >, Host=host1.domain.de, URI=/test/: New Host=host2.domain.de, New Path=/php/somepath/
< date > Rule ProxyPass : < v-server >, Host=host1.domain.de, URI=/test/: Using default pool < pool >
I simply want to redirect from host1.domain.de/test to host2.domain.de/php/somepath/ - I set up a data group with the following string:
host1.domain.de/test host2.domain.de/php/somepath/
But always when I make a request to host1.domain.de/test nothing happens - no redirect - as I can see in the log lines it simply redirects me to the same page... why??
I tried a simple case:
/test www.google.com
Could such line ever work?
All I saw is that the redirect is always to the same host / uri to which I made the initial request. - hoolio
Cirrostratus
Hi Andi,
Sorry, I think there was a mismatch in naming conventions. The ProxyPass rule is generally designed to hide the host and/or URI rewriting to transparently rewrite the requests before load balancing them. So it doesn't generally redirect. It looks like the intended ProxyPass functionality is working as the URI is being rewritten from /test/ to /php/somepath/.
If you want to redirect /test to /php/somepath/, you could use a simpler iRule like this:when HTTP_REQUEST { Check if URI is /test or /test/ switch [HTTP::path] { "/test" - "/test/" { HTTP::redirect "/php/somepath/" } } }
Aaron - Andi_102219
Nimbostratus
Thanks for your reply! The "simple iRule" is already in place but I need to replace the following from the apache config:RewriteCond %{HTTP_REFERER} ^https://host1.domain.de/.* RewriteRule ^/test/(.*) http://host2.domain.de/some/path/$1 [P] ProxyPassReverse /test/ http://host2.domain.de/some/path/
Therefore I took this proxypass iRule - to replace the above mentioned Apache rules.
How can I accomplish this with the proxypass iRule?
Thanks, Andi - hoolio
Cirrostratus
Do you want clients to see the change of the host and/or URI in the browser address bar? Or do you want to rewrite it transparently? Redirects will show the client the change. Rewrites will hide them. The ProxyPass rule uses rewrites.
The rewrite condition is checking of the referer starts with https://host1.domain.de/. The request rewriting is replacing /test/ with http://host2.domain.de/some/path/. The response rule is doing rewriting /test/ to http://host2.domain.de/some/path/.
Also, do you know if there is actually response headers (mainly redirects) and/or payload content that you want to rewrite from /test/ to http://host2.domain.de/some/path/? If so, you can use an iRule like this to rewrite the redirects:
http://devcentral.f5.com/wiki/default.aspx/iRules/RewriteHTTPRedirectHostname.html
And you can use a blank stream profile and STREAM::expression iRule to rewrite the response content:
http://devcentral.f5.com/wiki/default.aspx/iRules/stream__expression
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