Forum Discussion
Ryan_M
Nimbostratus
Mar 17, 2008http::host is not populated
It's my first iRule, and I know the answer's going to make me feel stupid, so please be gentle...
I'm trying to do a simple redirect to https. I created two virtual servers with the same IP...
hoolio
Cirrostratus
Mar 17, 2008Hi,
If you send a request 'GET /test.html' to the VIP, you aren't including the Host header, so the redirect will be to https://test.html. If you make a request using 'GET /test.html HTTP/1.0\r\nHost: test.example.com' the HTTP::host command will return test.example.com. I would guess that the web server is assuming a default host value for the request.
You could add a check to the iRule which redirects to the VIP's IP address if no host is specified. Or if you know that clients can be redirected to a single domain, you could hard code it.
Here is an example of the first option:
when HTTP_REQUEST {
Check if Host header value has a length
if {[string length [HTTP::host]]}{
Redirect to the requested host
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
} else {
Redirect to VIP's IP address
HTTP::redirect https://[IP::local_addr][HTTP::uri]
}
}
If you wanted to hardcode the domain for redirects when the Host header doesn't have a value, just change [IP::local_addr] to the host you want.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
