Question

stuck on 'welcome to nginx' gunicorn django ubuntu 16.04

I am stuck on the ‘welcome to nginx’ page and I need help. Here is what I have and tried.

Test passed: gunicorn --bind 0.0.0.0:8000 myapp.wsgi:application

/etc/systemd/system/gunicorn.service:

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=jarjar
Group=www-data
WorkingDirectory=/home/jarjar/myapp
ExecStart=/home/jarjar/myapp/myappenv/bin/gunicorn --workers 3 --bind unix:/home/jarjar/myapp/myapp.sock myapp.wsgi:application

[Install]
WantedBy=multi-user.target

/etc/nginx/sites-available/myapp:


server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name myapp.com www.myapp.com;
    return 301 https://$server_name$request_uri;

    root /home/jarjar/myapp;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/jarjar/myapp;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/jarjar/myapp/myapp.sock;
    }

    location ~ /.well-known {
        allow all;
    }
}


server {
    listen 443 ssl http2 default_server ;
    listen [::]:443 ssl http2 default_server;
    include snippets/ssl-myapp.com.conf;
    include snippets/ssl-params.conf;
}

sudo rm /etc/nginx/sites-available/default sudo systemctl start gunicorn sudo systemctl enable gunicorn sudo nginx -t sudo systemctl restart nginx

Show comments

Submit an answer


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!

Sign In or Sign Up to Answer

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.

Accepted Answer

This will never work because you’re redirecting http to https (server block with listen on 443) and there’s no location there (except if inside those includes)

If you’re running this site via http, remove the return 301 ... If you plan on serving it only in https, remove all location entries from the server entry that listens to 80 and put them inside the server block that listens to 443.

Try this:

rename your proxy_pass:

proxy_pass http://django_projectname_server;

and then, BEFORE your server entry

upstream django_projectname_server {
  server unix:/fullpath/to/sockfile.sock fail_timeout=0;
}

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

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.