首页 > 编程知识 正文

Nginx servername 啥意思localhost,出版印刷合同是啥意思

时间:2023-05-04 21:36:09 阅读:251088 作者:3619

前言 nginx version: nginx/1.20.1CentOS Linux release 7.9.2009 (Core) server_name _ 是啥意思?

server_name _没啥意思。我觉得应该把这个替换掉。

假设配置是这样的

nginx.conf

...http { ... # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80; listen [::]:80; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; ... }}...

/etc/nginx/default.d/目录下包含2个conf:

domainA.confdomainB.conf

nginx中有3个server_name,且生效顺序如下:

domainAdomainB_ 当访问 http://localhost 时

当访问 http://localhost 时,展示/usr/share/nginx/html/index.html的内容。
localhost 与 _匹配了(_=localhost)。

当访问 http://127.0.0.1 时

当访问 http://127.0.0.1 时,展示domainA的内容。
127.0.0.1 与domainA匹配了( 127.0.0.1 无法与三者之中的任何一个匹配,默认选取第一个)。

当访问 http://domainA 时

当访问 http://domainA 时,展示domainA的内容。

当访问 http://domainB 时

当访问 http://domainB 时,展示domainA的内容。

_=localhost

server_name _; 与 server_name localhost; 等效

server_name 默认配置

nginx.conf中的顺序改为:

...http { ... server { listen 80; listen [::]:80; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; ... } # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf;}...
jquery如何给元素增加宽度

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。