All configurations are being included and conf test is passed too. But Nginx is still serving the default HTML from /usr/share/nginx/html
, instead of location root from conf file in conf.d directory.
conf file from conf.d directory
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.$1;
}
}
The default nginx
config is in /etc/nginx/nginx.conf
. By default that file includes the following lines (at least that is the case on rhel based and arch based distros):
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 {
}
}
Thanks to the root
in the server
section nginx
will keep serving the files under that directory until you comment our these lines. This happens just after conf.d
is loaded (as noted in the snippet above).
No matter what you change inside conf.d
that last part of the file will still be loaded. Since it is that file (/etc/nginx/nginx.conf
) that loads the configs in conf.d
.
And yes, you definitely should comment out that default server
if you plan to use nginx
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With