Django + Nginx configuration: why getting “Welcome to nginx!"?

January 17, 2019 298 views
Nginx Django

I have Django + Nginx + Gunicorn on Ubuntu. Certificates generated with Letsencrypt.

In /etc/nginx/sites-available/myproject I have:

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;
    }
}

In /etc/nginx/sites-available/default, except commented lines, I have:

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;
    }
}

In /etc/nginx/sites-enabled I have default and myproject.

When I go to https://myproject.com, I see "Welcome to nginx!". What am I doing wrong that it redirects to "Welcome to nginx!"?

1 Answer

I wish someone would answer this I have the same problem!

Have another answer? Share your knowledge.