Forum Discussion
proxy to specific node with specific url
Hello,
I am trying to write iRule to accomplish this
Here is what I am trying to do
http://publicserver.com/engineering/las ---> internalserver.com:9290/las http://publicserver.com/engineering/thredds --> internalserver.pmel.noaa.gov:9290/thredds Any other requests goes to the default pool (default pool uses port 80).
My iRule is like this
when HTTP_REQUEST { if {([HTTP::uri] starts_with "/engineering/las")} { HTTP::uri "/las" node a.b.c.d:9290 log local0. "/ENGINEERING/LAS::::::[HTTP::host] THE-IFuri[HTTP::uri]" } elseif {([HTTP::uri] starts_with "/engineering/thredds")} { HTTP::uri "/thredds" node a.b.c.d:9290 log local0. "/ENGINEERING/THREDDS::::[HTTP::host] THE-uri2[HTTP::uri]" } else { pool public-pool } }
However my iRule does not work as I want it to do. Instead it is doing like this:
When a user is trying to go to http://publicserver.com/engineering/las or http://publicserver.com/engineering/thredds, the ltm is not sending (proxy) those request to internalserver.com:9290/las or internalserver.com:9290/thredds respectively, the ltm is sending the requests to publicserver.com/las or publicserver.com/thredds
Thanks for any help
17 Replies
- Michael_Jenkins
Cirrostratus
I think your syntax for the node command may be incorrect. You may need to add
s around it. And I'd use a"
statement instead. Something like this:switchwhen HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/engineering/las*" { HTTP::uri "/las" node a.b.c.d 9290 or node "a.b.c.d:9290" log local0. "/ENGINEERING/LAS::::::[HTTP::host] THE-IFuri[HTTP::uri]" } "/engineering/thredds*" { HTTP::uri "/thredds" node a.b.c.d 9290 or node "a.b.c.d:9290" log local0. "/ENGINEERING/THREDDS::::[HTTP::host] THE-uri2[HTTP::uri]" } default { log "default: '[HTTP::uri]'" pool public-pool } } }And what logs do you see in the ltm logs?
- tran_93981
Nimbostratus
Sorry for the typo that I posted. I have the syntax correct. I have "node a.b.c.d:9290" but when I posted it on Devcentral, I had it incorrectly. So syntax is not the cause. The log of LTM indicates the request is sent to the publicserver.com/thredds or publicserver.com/las not internalserver.com:9290/thredds or internalserver.com:9290/las
- Michael_Jenkins
Cirrostratus
can you add a line to the irule (log local0. "URL: '[HTTP::host][HTTP::uri]'") right below "when HTTP_REQUEST" and paste what you see in the logs when you test it?
- tran_93981
Nimbostratus
Hello,
The logs are:
TCL error: /Common/ferret-urls-selection - invalid command name "/engineering/las" while executing "[HTTP::uri] "/las"". (This has status code of 01220001)
Virtual /Common/ferret - Updated rule /Common/ferret-urls-selection when priority 32768000 (this has status code of 01220003
The requested rule (/Common/ferret-urls-selection) already exists in partition Common (status code 01020066)
- tran_93981
Nimbostratus
Hello,
The logs are:
TCL error: /Common/ferret-urls-selection - invalid command name "/engineering/las" while executing "[HTTP::uri] "/las"". (This has status code of 01220001)
Virtual /Common/ferret - Updated rule /Common/ferret-urls-selection when priority 32768000 (this has status code of 01220003
The requested rule (/Common/ferret-urls-selection) already exists in partition Common (status code 01020066)
- Michael_Jenkins
Cirrostratus
Can you run a test against the VS and see paste what logs it generates after that? these look like ones relating to saving the iRule
- tran_93981
Nimbostratus
Hello,
The logs are:
TCL error: /Common/ferret-urls-selection - invalid command name "/engineering/las" while executing "[HTTP::uri] "/las"". (This has status code of 01220001)
Virtual /Common/ferret - Updated rule /Common/ferret-urls-selection when priority 32768000 (this has status code of 01220003
The requested rule (/Common/ferret-urls-selection) already exists in partition Common (status code 01020066)
- tran_93981
Nimbostratus
Hello,
The logs are:
TCL error: /Common/ferret-urls-selection - invalid command name "/engineering/las" while executing "[HTTP::uri] "/las"". (This has status code of 01220001)
Virtual /Common/ferret - Updated rule /Common/ferret-urls-selection when priority 32768000 (this has status code of 01220003
The requested rule (/Common/ferret-urls-selection) already exists in partition Common (status code 01020066)
- tran_93981
Nimbostratus
Sorry for the late responses. I have replied but I may have done something incorrectly so the replies were not posted. The logs are: Rule /Common/ferret-urls-selection : THREDDS URL:'ferret.pmel.noaa.gov/thredds' from 161.55.85.37 Rule /Common/ferret-urls-selection : lAS URL:'ferret.pmel.noaa.gov/las' from 161.55.85.37 Rule /Common/ferret-urls-selection : THREDDS URL:'ferret.pmel.noaa.gov/thredds' from 161.55.85.37 Rule /Common/ferret-urls-selection : THREDDS URL:'ferret.pmel.noaa.gov/thredds' from 161.55.85.37
- Michael_Jenkins
Cirrostratus
Do the logs show that it's getting to the right spot and setting the pool member as expected?
- tran_93981
Nimbostratus
The request is sent to the right spot and to the right member (I captured the traffic) but the return traffic is came from the webpage of http://publicserver.com/las instead of http://internalserver.com:9290/las. We want if the request is for http://publicserver.com/engineering/las then go to pool internalserver.
- Michael_Jenkins
Cirrostratus
So a couple questions then. Are you saying the response page contains the wrong links in it or that the request it's going to the right server or the request isn't going to the right URI internally?
- tran_93981
Nimbostratus
It is going to the right server with right spot (means port 9290 in my interpretation for the "right spot") but the uri /las is not included in the request. It seems like I can only either has 'HTTP::uri /las' or 'pool my-internalserver' but I can not have both in my iRule.
- tran_93981
Nimbostratus
Is there iRule that could accomplish this:
if http://publicserver.com/engineering/las then go to internalserver.com:9290/las elseif http://publicserver.com/engineering/thredds then go to internalserver.com:9290/thredds else go to old-internalserver.com (default pool)
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