meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
sw:nginx:revproxy [2024/08/08 11:08] – created niziaksw:nginx:revproxy [2024/12/19 08:51] (current) niziak
Line 1: Line 1:
 ====== revproxy ====== ====== revproxy ======
 +
 +===== variables =====
 +
 +==== $host vs $http_host vs $server_name ====
 +
 +From: [[https://serverfault.com/questions/706438/what-is-the-difference-between-nginx-variables-host-http-host-and-server-na|What is the difference between Nginx variables $host, $http_host, and $server_name?]]
 +
 +**You should almost always use** ''$host'', as it's the only one guaranteed to have something sensible regardless of how the user-agent behaves, unless you specifically need the semantics of one of the other variables.
 +
 +The difference is explained in the nginx documentation:
 +  * ''$host contains'' "in this order of precedence: host name from the request line, or host name from the 'Host' request header field, or the server name matching a request"
 +  * ''$http_host'' contains the content of the HTTP "Host" header field, if it was present in the request
 +  * ''$server_name'' contains the server_name of the virtual host which processed the request, as it was defined in the nginx configuration. If a server contains multiple server_names, only the first one will be present in this variable.
 +
  
 ===== app behind path ===== ===== app behind path =====