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, one on 443, one on 80. The VS on 80 has this iRule applied:
when HTTP_REQUEST {
HTTP::redirect https://[HTTP::host][HTTP::uri]
}
However, when I try to access this server, I get this HTTP response:
GET /test.html
HTTP/1.0 302 Found
Location: https:///test.html
Server: BIG-IP
Connection: close
Content-Type: text/html
Content-Length: 0
HTTP::uri is working alright, so why is HTTP::host staying blank? If I replace [HTTP::host] with a static hostname, the redirect works properly.
The web application is seeing a proper HTTP_HOST, so from what I can tell, nothing's getting mangled. The only unusual thing about this we don't have a reverse DNS entry for this system (but that shouldn't matter, right?).
Thanks,
Ryan
- hoolio
Cirrostratus
Hi,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] } }
- Ryan_M
Nimbostratus
Wow. If I understand you correctly, then this is a valuable lesson in many ways. I was convinced that http_host was set by the server, not by the client; however, it appears I'm wrong. - hoolio
Cirrostratus
The host is a value the client should set (optional in HTTP 1.0, required in HTTP 1.1) to indicate which web application on the web server it is making a request to. The idea was to allow servers to support multiple web applications without needing a separate IP address and port per web app. So yes, the client is supposed to tell the server which host it's making the request to. I would guess that you're web server is setting the HTTP_HOST CGI variable to the default HTTP host on the server if the client doesn't specify a host. Most clients (ie, all modern browsers) will specify the fully qualified domain in the address bar for a request in the HTTP host header, so this shouldn't really be an issue in most cases.
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