URL

请求示例

  1. curl http://example.com/path/to/image.jpg?size=320&v=1

变量解析

  1. $scheme http
  2. $uri /path/to/image.jpg
  3. $args size=320&v=1
  4. $request_uri /path/to/images.jpg?size=320&v=1
  5. # HTTP 请求行
  6. $request "GET /path/to/image.jpg?size=320&v=1 HTTP/1.1"
  7. # 域名
  8. $host example.com
  9. $http_host example.com

有关于 $host 和 $http_host 区别,官方有以下说明:

$host 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 more

In this configuration nginx tests only the request’s header field “Host” to determine which server the request should be routed to. If its value does not match any server name, or the request does not contain this header field at all, then nginx will route the request to the default server for this port. more

参考