0

I was trying to deploy a Django web app to Digital Ocean following this gist. It is written based on a tutorial from digital ocean themselves. Everything seem to be working perfectly fine until it's time to setup Nginx.

I follow it exactly every time and it always sends me a 502 Bad Gateway message.

1
  • You need to post your config.
    – farooq
    Mar 10, 2019 at 1:42

1 Answer 1

0
server {
    listen 80;
    server_name your_droplet_ip:8000 www.your_droplet_ip:8000;

    root /var/www/html;

     location / {
             proxy_pass http://your_droplet_ip:8000;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header Host $http_host;
             proxy_set_header X-NginX-Proxy true;

              }
     }

try this and after run service nginx restart

4
  • Hey @coderasha this kind of worked because now I can at least see welcome to nginx, but shouldn't my website be there instead of their welcome page?
    – A. Atiyah
    Mar 10, 2019 at 17:23
  • Did you run python3 manage.py runserver your_droplet_ip:8000 in your terminal?
    – thepylot
    Mar 10, 2019 at 19:55
  • It worked! I don't know why but I followed the exact same steps again and it worked out this time.
    – A. Atiyah
    Mar 10, 2019 at 21:09
  • Glad to hear it! Additional information: After you change debug=True to debug=False Django will not serve static and media files, so instead Nginx will serve these files check my comment here and follow steps: [stackoverflow.com/questions/55054261/…
    – thepylot
    Mar 10, 2019 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.