Forum Discussion
will this irule work?
Need a rule to do this :
client comes into the VS with "/admin" in the URI.. if they have /admin then want to be redirected to come back with /someother/index in the URI and drop into the ADMIN POOL (retaining the hostname)
if they dont have it, then drop to MY-OTHER-POOL
when HTTP_REQUEST { if {[HTTP::uri] contains "/admin"} {HTTP::redirect "https://[getfield [HTTP::host] ":" 1]/someother/index" } if {[HTTP::uri] contains "/someother/index"} pool MY-ADMIN-POOL } else {pool MY-OTHER-POOL} }
17 Replies
- Michael_Jenkins
Cirrostratus
I think this rule should work, though I'd make a couple tweaks.
when HTTP_REQUEST { switch -glob -- [string tolower [HTTP::uri]] { "*/admin*"} { HTTP::host should be fine as long as you're using the default port. If you use a different port than default, you'll need to parse the host. If you know you're already on HTTPS, you could just use "/someother/index" too HTTP::redirect "https://[HTTP::host]/someother/index" return } "*/someother/index*" { pool MY-ADMIN-POOL } default { pool MY-OTHER-POOL } } } Actually its not a http > https redirect, its a http only..
Thats a typo
when HTTP_REQUEST { if {[HTTP::uri] contains "/admin"} {HTTP::redirect "http://[getfield [HTTP::host] ":" 1]/someother/index" } if {[HTTP::uri] contains "/someother/index"} pool MY-ADMIN-POOL } else {pool MY-OTHER-POOL} }
- Michael_Jenkins
Cirrostratus
In that case, this might work
when HTTP_REQUEST { switch -glob -- [string tolower [HTTP::uri]] { "*/admin*"} { HTTP::redirect "/someother/index" return } "*/someother/index*" { pool MY-ADMIN-POOL } default { pool MY-OTHER-POOL } } } its the one further up in this question..
when HTTP_REQUEST { switch -glob -- [string tolower [HTTP::uri]] { "/admin"} { HTTP::redirect "/hawtio/index" return
} "/hawtio/index" { pool MY-ADMIN-POOL } default { pool MY-OTHER-POOL } } }- Michael_Jenkins
Cirrostratus
try this. Noticed I had an extra } in the one above. Sorry about that...
when HTTP_REQUEST { log local0. "URI: [HTTP::uri]" switch -glob -- [string tolower [HTTP::uri]] { "/admin*" { log local0. " Redirect to /hawtio/index" HTTP::redirect "/hawtio/index" return } "/hawtio/index*" { log local0. " Set pool to MY-ADMIN-POOL" pool MY-ADMIN-POOL } default { log local0. " Set pool to MY-OTHER-POOL" pool MY-OTHER-POOL } } } when HTTP_RESPONSE { log local0. " Response code: [HTTP::status]" } Hi.. no need to apologise.. i just wish the F5 would tell me what the issue is in English..
Anyway it took the the irule commands ok but when it redirects to the "/hawtio/index" its giving me a 404.. (not found)
The servers in the "ADMIN" pool are listening on a different port [8181] for that website so the redirect is forcing back to the Virtual server which i guess cant serve the page from that pool.
- Michael_Jenkins
Cirrostratus
OK. i updated the rule to add "*" to the switch. Try again with that and see if it helps.
afraid not..
If i hit the servers directly via IP address the site is working fine.. but I need to :8181 to produce the page..
10.10.10.10:8181/hawito/index
I am wondering if the Virtual server could ever produce the page unless its the default pool ?
- Michael_Jenkins
Cirrostratus
are you using https on your virtual at all? are you using a serverside or clientside ssl profile?
Theres no https in this at all ..
- Michael_Jenkins
Cirrostratus
I updated the rule again. see what the logs say when you try again...
looks like its dropping through to the correct pool to me ?
Thu Jan 15 20:22:30 GMT 2015 info lb101 tmm3[9968] Rule /Common/L7-CONTENT-Irule : URI: /admin Thu Jan 15 20:22:30 GMT 2015 info lb101 tmm3[9968] Rule /Common/L7-CONTENT-Irule : Redirect to /hawtio/index Thu Jan 15 20:22:30 GMT 2015 info lb101 tmm3[9968] Rule /Common/L7-CONTENT-Irule : URI: /hawtio/index Thu Jan 15 20:22:30 GMT 2015 info lb101 tmm3[9968] Rule /Common/L7-CONTENT-Irule : Set pool to MY-ADMIN-POOL
sorry found this bit on the next page..
Thu Jan 15 20:22:30 GMT 2015 info tmm3[9968] Rule /Common/-L7-CONTENT-Irule : Response code: 404
- Michael_Jenkins
Cirrostratus
since you're getting a 404 returned, it appears that the request is going to your backend server. you could try tcpdump and monitor the traffic from the VIP to the backend and see what's happening. if you do "http://x.x.x.x:yyyy/hawtio/index", you said that works?
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