Forum Discussion
kg_50758
Nimbostratus
Jul 25, 2007Standard HTTPs redirect
I am new to iRules, when i tried the standard https redirect if the url ends with '.do, could not get it to working. iRules i used is as below
when HTTP_REQUEST {
if { [HTTP::uri] ends_with "*.do" } {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
}
Also tried below iRules, just to redirect all the trafic to https, even this is not working for me.
when HTTP_REQUEST {
set uri [HTTP::uri]
HTTP::redirect "https://[HTTP::host]$uri"
}
I want https redirect to happen on the client to f5 and not on the f5 to server.
client--->f5--->server
Searched for the solution in the forum, could not find one. Can some one HELP.
Thanks in Advance
KG
- hoolio
Cirrostratus
You might want to compare with HTTP::path instead of HTTP::uri. HTTP::uri contains the query string as well as the path/object, whereas HTTP::path contains only the path/object. Can you try the following:when HTTP_REQUEST { log local0. "client [IP::client_addr] -> [HTTP::host] for uri: [HTTP::uri], path: [HTTP::path] if { [HTTP::path] ends_with ".do" } { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] } }
- kg_50758
Nimbostratus
Thanks for your response Aaron. - hoolio
Cirrostratus
The syslog-ng local0.* facility is sent to /var/log/ltm by default. You can either view the file using the command line (with 'tail -f /var/log/ltm' or less /var/log/ltm), or use the GUI's log section under System | Logs | Local Traffic. - kg_50758
Nimbostratus
When i take out the 'if' statement from the iRule code you provided, the browser keeps loading forever and not bringing up the next page. Any idea what would be the problem, could not see any useful information in the logs. - hoolio
Cirrostratus
Are you applying the redirect rule to the HTTP virtual server? I would have assumed you wanted to redirect the HTTP requests to the same URI, but via HTTPS. It sounds like you may have the rule applied to the HTTPS virtual server. - kg_50758
Nimbostratus
Aaron, i am sure that iRules is applied to https. Below are the logs entry from GUI, - hoolio
Cirrostratus
I'm not sure what you're overall goal is then. I assumed you wanted to redirect some HTTP requests to the same URI but via HTTPS. If you're applying the iRule to an HTTPS virtual server, the request is already being made over HTTPS. So as expected, you will get a looping redirect. - kg_50758
Nimbostratus
Sorry i missed "not" (applied to https) in my previous message. Your understanding is correct i want to redirect http request to https for some uri. Even for all http request the redirect is not working: page loads for long time and gives page cannot be displayed message. Thanks!. - hoolio
Cirrostratus
If you have the iRule applied only to an HTTP virtual server without the if statement, all requests should be redirected to the same host and URI from the request but to HTTPS. If you were seeing endless looping, it either means you had the same iRule applied to the HTTPS virtual server, you have a single virtual server which is listening on any port, or the application is redirecting https requests to http.when HTTP_REQUEST priority 501 { set request_info "client: [IP::client_addr] -> ([virtual name] - [IP::local_addr]:[TCP::local_port]) [HTTP::host][HTTP::uri]" } when HTTP_RESPONSE priority 501 { set headers "Headers: " foreach aHeader [HTTP::header names] { set headers "$headers$aHeader: [HTTP::header value $aHeader] " } log local0. "Request Info: $request_info; Response Info: status: [HTTP::status]; $headers" }
- kg_50758
Nimbostratus
Aaron,
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