Nginx 包括来自 conf.d 的 conf 但仍在加载默认设置
Nginx including conf from conf.d but still loading default settings
所有配置都包含在内,conf测试也通过了。但是 Nginx 仍在 /usr/share/nginx/html
中提供默认的 HTML,而不是 conf.d 目录中的 conf 文件中的根目录。
conf 文件 来自 conf.d 目录
upstream django {
server unix:///tmp/server.sock;
}
server {
listen 80;
server_name server.test.com;
access_log /srv/source/logs/access-nginx.log;
error_log /srv/source/logs/error-nginx.log;
location / {
uwsgi_pass django;
include /srv/source/conf/uwsgi/params;
}
location /static/ {
root /srv/source/;
index index.html index.htm;
}
location /media/ {
root /srv/source/media/;
index index.html index.htm;
}
# alias favicon.* to static
location ~ ^/favicon.(\w*)$ {
alias /srv/source/static/favicon.;
}
}
默认 nginx
配置在 /etc/nginx/nginx.conf
中。默认情况下,该文件包含以下行(至少在基于 rhel 和基于 arch 的发行版上是这样):
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
感谢 server
部分中的 root
nginx
将继续提供该目录下的文件,直到您评论我们的这些行。这发生在 conf.d
加载之后(如上面的代码片段所述)。
无论您在 conf.d
中进行什么更改,文件的最后一部分仍将被加载。因为正是那个文件 (/etc/nginx/nginx.conf
) 加载了 conf.d
.
中的配置
是的,如果您打算使用 nginx
.
,您绝对应该注释掉默认值 server
所有配置都包含在内,conf测试也通过了。但是 Nginx 仍在 /usr/share/nginx/html
中提供默认的 HTML,而不是 conf.d 目录中的 conf 文件中的根目录。
conf 文件 来自 conf.d 目录
upstream django {
server unix:///tmp/server.sock;
}
server {
listen 80;
server_name server.test.com;
access_log /srv/source/logs/access-nginx.log;
error_log /srv/source/logs/error-nginx.log;
location / {
uwsgi_pass django;
include /srv/source/conf/uwsgi/params;
}
location /static/ {
root /srv/source/;
index index.html index.htm;
}
location /media/ {
root /srv/source/media/;
index index.html index.htm;
}
# alias favicon.* to static
location ~ ^/favicon.(\w*)$ {
alias /srv/source/static/favicon.;
}
}
默认 nginx
配置在 /etc/nginx/nginx.conf
中。默认情况下,该文件包含以下行(至少在基于 rhel 和基于 arch 的发行版上是这样):
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
感谢 server
部分中的 root
nginx
将继续提供该目录下的文件,直到您评论我们的这些行。这发生在 conf.d
加载之后(如上面的代码片段所述)。
无论您在 conf.d
中进行什么更改,文件的最后一部分仍将被加载。因为正是那个文件 (/etc/nginx/nginx.conf
) 加载了 conf.d
.
是的,如果您打算使用 nginx
.
server