Forum Discussion
Nikoolayy1
MVP
Jan 25, 2022Knowledge sharing: Containers, Kubernetes, Openshift, F5 Container Connector, NGINX Ingress
For anyone interested about the free traning for "F5 Container Connector for Kubernetes" or "F5 OpenShift Container Integration" at "LearnF5". For NGINX being installed in Kubernetes there ...
Hi there,
I think that's a slight mis-statement. I'm pretty sure the host in the redirect location is not checked against the request. The 9.4.5 and 9.3.1 online help shows:
Redirect Rewrite
Specifies whether the system rewrites the URIs that are part of HTTP redirect (3XX) responses. The default is None.
* None: Specifies that the system does not rewrite the URI in any HTTP redirect responses.
* All: Specifies that the system rewrites the URI in all HTTP redirect responses.
* Matching: Specifies that the system the URI in any HTTP redirect responses that match the request URI.
* Nodes: Specifies that if the URI contains a node IP address instead of a host name, the system changes it to the virtual server address.
If you want to rewrite the redirect to https if the host in the Location header matches a predefined host you could hardcode it like this:
when HTTP_RESPONSE {
Check if response is a redirect
if {[HTTP::is_redirect]}{
Rewrite the location header if it matches a hardcoded host value
HTTP::header replace Location [string map -nocase "http://www.example.com https://www.example.com" [HTTP::header value Location]]
}
}
A more general (but less efficient) option would be to save the Host header value on every request and check if the Location header starts with it:
when HTTP_REQUEST {
Save host header in lower case
set host [string tolower [HTTP::host]]
}
when HTTP_RESPONSE {
Check if response is a redirect
if {[HTTP::is_redirect] and [string tolower [HTTP::header value Location]] starts_with "http://$host"}{
Rewrite the location header if it matches a hardcoded host value
HTTP::header replace Location [string map -nocase "http:// https://" [HTTP::header value Location]]
}
}
Aaron
- Cory_50405Mar 06, 2014
Noctilucent
Could you specify what your requirements are? These products can do many different things, so best to narrow it down to the exact functionality you are using the DataPower for and what you expect out of ASM.