configuration - Nginx 中 $host 和 $http_host 有什么区别

标签 configuration nginx http-headers

在Nginx中,变量$host$http_host有什么区别。

最佳答案

$hostCore 的变量模块。

$host

This variable is equal to line Host in the header of request or name of the server processing the request if the Host header is not available.

This variable may have a different value from $http_host in such cases: 1) when the Host input header is absent or has an empty value, $host equals to the value of server_name directive; 2)when the value of Host contains port number, $host doesn't include that port number. $host's value is always lowercase since 0.8.17.

$http_host 也是同一模块的变量,但您不会用该名称找到它,因为它一般定义为 $http_HEADER ( ref ) .

$http_HEADER

The value of the HTTP request header HEADER when converted to lowercase and with 'dashes' converted to 'underscores', e.g. $http_user_agent, $http_referer...;

<小时/>

总结:

  • $http_host 始终等于 HTTP_HOST 请求 header 。
  • $host 等于 $http_host小写且不带端口号(如果存在),除非 HTTP_HOST 不存在或者为空值。在这种情况下,$host 等于处理请求的服务器的 server_name 指令的值。

关于configuration - Nginx 中 $host 和 $http_host 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15414810/

相关文章:

java - Camel sftp 制作者。如何从单个处理器将多个文件放入不同的 sftp 文件夹

我的应用程序的 Android APK 下载不起作用,Xamarin.Android

java - 我如何使用 log4j2 为不同的类使用不同的日志记录级别?

asp.net - 如何配置 SlickUpload 6 AJAX 不需要文件

php - Nginx:X-Accel-Redirect 在具有已知 MIME 扩展名的文件中不起作用

django - 如何优雅地重新启动在 nginx 后面运行 fcgi 的 django?

javascript - 正则表达式匹配接受语言 header

http - 通过 HTTP 传输文件

node.js - Chrome 没有呈现分块的 json 响应

nginx - nginx-ingress适用于/,但不适用于子路径