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
I think your syntax for the node command may be incorrect. You may need to add
"
s around it. And I’d use a
switch
statement instead. Something like this:
when 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?
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
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?
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)
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)
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
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)
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)
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
Do the logs show that it’s getting to the right spot and setting the pool member as expected?
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.
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?
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.
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)
You could try setting the pool for new-internalserver.com as the default pool on the VS, and then update the URI in the iRule, and then change the pool for any others that don’t match to the old server pool
Thank you Michael. I will definitely try your suggestion. I need to schedule the maintenance time for this. I will update you how does it go.
Hello,
Sorry it took long to post this. I had not have a chance to try it until yesterday. I tried your suggestion but unfortunately, it does not solve problem. So the irule is written like this
when HTTP_REQUEST {
log local0. "[HTTP::uri] ****"
if {([HTTP::uri] starts_with "/engineering/las")} {
log local0. "redirecting to /las"
HTTP::uri "/las/"
} elseif {([HTTP::uri] starts_with "/engineering/thredds")} {
log local0. "redirecting to /thredds"
HTTP::uri "/thredds/"
} else {
log local0. "using pool yaquina-only"
pool yaquina-only
}
}
What I am experiencing with this re-written irule is: the "else" statement works but the "if" and "elseif" do not work. When a user tries to get to http://publicserver.com/engineering/las, the page displays saying "not found". I believe it is because the "if" changes the uri and the requests becomes http://publicserver.com/las then that request matches the "else" statement.