Report this

What is the reason for this report?

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

Posted on January 17, 2019

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!”?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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

Did you try removing default from /etc/nginx/sites-enabled?

sudo rm /etc/nginx/sites-enabled/default

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.