Proxy request using iRule

Hi,

We’re trying to proxy requests from the external address https://mydomain.com/application/login/default.php to an internal server . I think the iRule at the link below can do what we want, but when we tried to impliment it, it didn’t work and it’s probably because the datagroup isn’t setup correctly.

The Pool name is “MyApp” but I’m not sure how to create the datagroup and make it look for addresses with /application/ and redirect them to myapp.local and remove /application/ from the request.

Thanks!

Hi Mike,

If you’re on 10.x you’d want to use this version:

http://devcentral.f5.com/wiki/default.aspx/iRules/ProxyPassV10.html

If you just want to do URI rewriting, you should be able to configure the datagroup as

External datagroup format

“mydomain.com/application” := “myapp.local/”,

Internal datagroup format (requires 10.1+)

“mydomain.com/application” { “myapp.local/” }

Or in the GUI:

name: mydomain.com/application

value: myapp.local/

Aaron

Yea we’re on 10.0+ finding the older version was a lot easier than the new one, thanks for that link.

I’ve applied the iRule to my virtual server and created the datagroup with the following records:

“/google” := google.com

“172.18.252.254/test-google” := google.com

When I go to /google I get an iis welcome.png which I’m guessing is from the default Pool. It’s finding the rule and says it’s talking to the new host, but instead it seems to be going to the default pool instead. The author makes this look so simple to setup! I tried setting the default pool to none, but that didn’t work either. Suggestions?

Wed Jan 19 17:09:23 EST 2011 info local/tmm1 tmm1[4593] Rule ProxyPass : VS=Elephant_LAB_VS, Host=172.18.252.254, URI=/google/welcome.png: Changing Referer header: http://172.18.252.254/google/ to http://google.com/

Wed Jan 19 17:09:23 EST 2011 info local/tmm1 tmm1[4593] Rule ProxyPass : VS=Elephant_LAB_VS, Host=172.18.252.254, URI=/google/welcome.png: New Host=google.com, New Path=/welcome.png

Wed Jan 19 17:09:23 EST 2011 info local/tmm1 tmm1[4593] Rule ProxyPass : VS=Elephant_LAB_VS, Host=172.18.252.254, URI=/google/welcome.png: Using default pool Elephant_LAB_VS_RootPool

Wed Jan 19 17:09:23 EST 2011 info local/tmm1 tmm1[4593] Rule ProxyPass : VS=Elephant_LAB_VS, Host=172.18.252.254, URI=/google/welcome.png: Found Rule, Client Host=172.18.252.254, Client Path=/google, Server Host=google.com, Server Path=

Wed Jan 19 17:09:23 EST 2011 info local/tmm1 tmm1[4593] Rule ProxyPass : VS=Elephant_LAB_VS, Host=172.18.252.254, URI=/google/: New Host=google.com, New Path=/

Wed Jan 19 17:09:23 EST 2011 info local/tmm1 tmm1[4593] Rule ProxyPass : VS=Elephant_LAB_VS, Host=172.18.252.254, URI=/google/: Using default pool Elephant_LAB_VS_RootPool

Wed Jan 19 17:09:23 EST 2011 info local/tmm1 tmm1[4593] Rule ProxyPass : VS=Elephant_LAB_VS, Host=172.18.252.254, URI=/google/: Found Rule, Client Host=172.18.252.254, Client Path=/google, Server Host=google.com, Server Path=

Wed Jan 19 17:09:23 EST 2011 info local/tmm1 tmm1[4593] Rule ProxyPass : Elephant_LAB_VS: 172.18.1.111:62007 → 172.18.252.254:80