Hi, In the docs of $host at http://nginx.org/en/docs/http/ngx_http_core_module..., it says: $host Host request header field, or the server name matching a request if this field is not present It's not right with the host header like: www.example.com:1234. The $host variable always strips the port.
on 2012-11-30 04:18
on 2012-11-30 08:08
On Fri, Nov 30, 2012 at 11:18:15AM +0800, 姚伟斌 wrote:
> variable always strips the port.
How's this instead?
%%%
Index: xml/en/docs/http/ngx_http_core_module.xml
===================================================================
--- xml/en/docs/http/ngx_http_core_module.xml (revision 775)
+++ xml/en/docs/http/ngx_http_core_module.xml (working copy)
@@ -2754,8 +2754,10 @@
<tag-name id="var_host"><var>$host</var></tag-name>
<tag-desc>
-<header>Host</header> request header field,
-or the server name matching a request if this field is not present
+in this order of precedence:
+host from the request line, or
+host from the <header>Host</header> request header field,
+or the server name matching a request
</tag-desc>
<tag-name id="var_hostname"><var>$hostname</var></tag-name>
%%%
on 2012-11-30 11:06
Hi Ruslan, Most of the content is fine for me. Could you add a line like that the variable $host exclude the port explicitly? I know the host should mean the server name, not include the port. It just confuses me when I use the directive like this: proxy_set_header Host $host; But the port is missing. Maybe I shoud use the $http_host instead. Thanks. 2012/11/30 Ruslan Ermilov <ru@nginx.com>
on 2012-11-30 11:37
On Fri, Nov 30, 2012 at 06:05:42PM +0800, 姚伟斌 wrote: > Hi Ruslan, > > Most of the content is fine for me. Could you add a line like that the > variable $host exclude the port explicitly? I know the host should mean the > server name, not include the port. : GET http://example.com:12345/uri HTTP/1.1 : Host: example.net:54321 results in $host being set to "example.com", while : GET /uri HTTP/1.1 : Host: example.net:54321 results in $host being set to "example.net", as required by http://tools.ietf.org/html/rfc2616#section-5.2 If I say about port stripping in case #2, should I say about requestURI stripping to extract the "host" part? I'd like to avoid detailing it too much, and in my opinion "host from the ..." fits both cases. > It just confuses me when I use the > directive like this: > > proxy_set_header Host $host; > > But the port is missing. That is understood. The previous description was incorrect. Thanks for noticing. > Maybe I shoud use the $http_host instead. It depends on what you need. > 2012/11/30 Ruslan Ermilov <ru@nginx.com> [...]
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.