Forum Discussion
Facing sporadic issue with the redirection
Hi, we are facing sporadic issue with the redirection on "HTTP". Some times redirection works but sometimes it gives page not displayed.
Rule xyz-irule
when HTTP_REQUEST { switch -glob [string tolower [HTTP::host][HTTP::uri]] { "/abc" {HTTP::redirect "https://abc.xyz.com"} "/def" {HTTP::redirect "https://def.xyz.com"} "/ghi" {HTTP::redirect "https://ghi.xyz.com"} "*" {HTTP::redirect "http://www.test.xyz.com"}
IRules sequence iRules: xyz-irule : http_to_https_redirect : x-forwarding_Rule
I know 2nd rule is not applicable in this case because we have used "*" in first Rule, and not sure if X-Forwording rule is trying something which fails request sometimes.
rule x-forwarding_Rule
when HTTP_REQUEST { HTTP::header insert X-Forwarded-For [IP::remote_addr] } }
2 Replies
- Vijay_E
Cirrus
It looks like you are intending to match based on URI but your iRule is matching on both host header & URI: [string tolower [HTTP::host][HTTP::uri]]. If my understanding is right, you should use [string tolower [HTTP::uri]]
If you any CDN traffic, try using OneConnect with /32 netmask.
Use a combined iRule for simplicity:
when HTTP_REQUEST { HTTP::header insert X-Forwarded-For [IP::remote_addr] switch -glob [string tolower [HTTP::uri]] { "/abc" {HTTP::redirect "https://abc.xyz.com"} "/def" {HTTP::redirect "https://def.xyz.com"} "/ghi" {HTTP::redirect "https://ghi.xyz.com"} "*" {HTTP::redirect "http://www.test.xyz.com"} } } Hi Himanshu,
it doesn't make much sense for me to insert the
header for every incomming requests if you continue toX-Forwarded-For
every single requests.HTTP::redirectThe
header has no benefits forX-Forwarded-For
and even worse it will just disrupt the ongoing TCP session if you try to manipulate the HTTP request after it has been already responded. In addition you will see the error message below in your LTM logs...HTTP::redirectsOperation not supported (line 1) invoked from within "HTTP::header insert X-Forwarded-For [IP::remote_addr]"Cheers, Kai
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