Forum Discussion
Michael_Cope_10
Nimbostratus
Oct 03, 2005HTTP::redirect inside switch {} works but generates errors
I've got a large number of ssl vips on the same ip on different ports. I set up an irule to redirect port http requests to https+port. This works but with extraneous errors which I don't understand.
My irule:
HTTP_REQUEST {
switch [HTTP::host] {
integration.intranet.ny.gm.intranet.db.com { [HTTP::redirect "https://integration.intranet.ny.gm.intranet.db.com:2217"] }
...
}
}
generates error:
Oct 2 09:51:43 tmm tmm[19901]: 01220001:3: TCL error: Rule usi1_http_redirect_for_https - invalid command name "" while executing "[HTTP::redirect "https://integration.intranet.ny.gm.intranet.db.com:2217"] " ("integration.intranet.ny.gm.intranet.db.com" arm line 1) invoked from within "switch [HTTP::host] { integration.intranet.ny.gm.intranet.db.com { [HTTP::redirect "https://integration.intranet.ny.gm.intranet.db.co..."
but works:
zsh> wget -Yoff integration.intranet.ny.gm.intranet.db.com
--15:05:28-- http://integration.intranet.ny.gm.intranet.db.com/
=> `index.html'
Resolving integration.intranet.ny.gm.intranet.db.com... 10.152.98.200
Connecting to integration.intranet.ny.gm.intranet.db.com[10.152.98.200]:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://integration.intranet.ny.gm.intranet.db.com:2217 [following]
--15:05:28-- https://integration.intranet.ny.gm.intranet.db.com:2217/
=> `index.html'
Connecting to integration.intranet.ny.gm.intranet.db.com[10.152.98.200]:2217... connected.
Note that what I really want to write is
when HTTP_REQUEST {
switch [HTTP::host] {
integration.intranet.ny.gm.intranet.db.com { [HTTP::redirect "[HTTP:host]:2217[HTTP:uri]"] }
...
}
}
But that fails with a similar error
Sep 29 18:05:14 tmm tmm[710]: 01220001:3: TCL error: Rule usi1_http_redirect_for_https - invalid command name "" while executing "[HTTP::redirect "https//[HTTP::host][HTTP::uri]"] " ("integration.gedny.cio.gto.intranet.db.com" arm line 1) invoked from within "switch [HTTP::host] { integration.intranet.ny.gm.intranet.db.com { HTTP::redirect "https//[HTTP::host]:2217[HTTP::uri]" } ..."
Then doesn't work...
- Brian_Gupta_115
Nimbostratus
Suggestion: try this rule.
Click here http://devcentral.f5.com/Default.aspx?tabid=28&view=topic&forumid=5&postid=2168rule http2https_redirect { when HTTP_REQUEST { HTTP::redirect https://[HTTP::host][HTTP::uri] } }
- Brian_Gupta_115
Nimbostratus
As an additional note, read up on switch here: Click here http://tmml.sourceforge.net/doc/tcl/ - unRuleY_95363Historic F5 AccountThe problem is that you have the redirect command in square brackets []. The square brackets evaluate the command inside the brackets and then place the result where the brackets are. So, you end up evaluating the redirect and then try to execute the result of the redirect which is the empty string. Just remove the square brackets and it should work without generating an error.
- Michael_Cope_10
Nimbostratus
Brian, - Brian_Gupta_115
Nimbostratus
It looks like you have an interesting naming scheme/configuration for your VIPs. Would you be interested in sharing what you are doing? (Either here or offline if you prefer)...
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