Django + Nginx配置(获取“欢迎使用nginx!”)

时间:2019-01-17 21:45:48

标签: django nginx

我在Ubuntu上有Django + Nginx + Gunicorn。用Letsencrypt生成的证书。

/ etc / nginx / sites-available / myproject 中,我有:

server {
    server_name myproject.com www.myproject.com;
    listen 80;
    return 301 https://myproject.com$request_uri;
}

server {
    server_name myproject.com www.myproject.com;

    listen 443;

    ssl on;
    ssl_certificate /etc/letsencrypt/live/myproject.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/myproject.com/privkey.pem;

    client_max_body_size 1G;

    root /home/myname/myproject;

    location / {
        include proxy_params;
        proxy_pass https://unix:/home/myname/myproject/myproject.sock;
    }
}

/ etc / nginx / sites-available / default 中,除了注释行外,我有:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
            try_files $uri $uri/ =404;
    }
}

/ etc / nginx / sites-enabled 中,我具有默认值和myproject。

当我转到https://myproject.com时,看到“欢迎使用nginx!”,但是我希望看到Django的默认页面。 将其重定向到“欢迎使用nginx!”,我在做什么错?

1 个答案:

答案 0 :(得分:0)

只需禁用默认配置:

rm /etc/nginx/sites-enabled/default
systemctl reload nginx