Hello,

>From the current documentation it was not immediately obvious (at least
to me and my colleague) that nginx does not set the $proxy_host variable
to the hosts specified in an upstream block, but literally uses the name
used in the proxy_pass directive.

Maxim Dounin has explained to me the reason for this [1], nevertheless I
think it is worthwhile explicitly adding this behavior to the documentation.

Regards
Jack

[1] http://mailman.nginx.org/pipermail/nginx/2018-November/057184.html

# HG changeset patch
# User Jack Henschel <jack...@mailbox.org>
# Date 1543937160 -3600
#      Tue Dec 04 16:26:00 2018 +0100
# Node ID 4db5b4e69bc01652fec910827ce404cdeccaf104
# Parent  e2e71f9477a8026c54f7c5432cd7c88865120fc9
Clarify proxy modules $proxy_host variable content

>From the current documentation it was not immediately obvious that
nginx does not set the $proxy_host variable to the hosts specified
in an upstream block, but literally uses the name used in the
proxy_pass directive.
This patch clarifies this behavior. Based on the following exchange:
http://mailman.nginx.org/pipermail/nginx/2018-November/057184.html

diff -r e2e71f9477a8 -r 4db5b4e69bc0 xml/en/docs/http/ngx_http_proxy_module.xml
--- a/xml/en/docs/http/ngx_http_proxy_module.xml	Fri Nov 30 18:28:54 2018 +0300
+++ b/xml/en/docs/http/ngx_http_proxy_module.xml	Tue Dec 04 16:26:00 2018 +0100
@@ -1386,6 +1386,11 @@
 used in a round-robin fashion.
 In addition, an address can be specified as a
 <link doc="ngx_http_upstream_module.xml">server group</link>.
+Note that nginx will stil use the name specified in the
+<literal>proxy_pass</literal> directive as the
+<link id="var_proxy_host"><var>$proxy_host</var>variable</link>,
+not the the hostnames of the individual servers specified in the
+upstream block.
 </para>
 
 <para>
diff -r e2e71f9477a8 -r 4db5b4e69bc0 xml/en/docs/http/ngx_http_upstream_module.xml
--- a/xml/en/docs/http/ngx_http_upstream_module.xml	Fri Nov 30 18:28:54 2018 +0300
+++ b/xml/en/docs/http/ngx_http_upstream_module.xml	Tue Dec 04 16:26:00 2018 +0100
@@ -47,6 +47,11 @@
     }
 }
 </example>
+Note that in the above example nginx will use the name specified in the
+<link doc="ngx_http_proxy_module.xml" id="proxy_pass">proxy_pass</link>
+directive as the <link doc="ngx_http_proxy_module.xml" id="var_proxy_host">
+<var>$proxy_host</var> variable</link>, not the the hostnames of the
+individual servers specified in the upstream block.
 </para>
 
 <para>

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to