[Answered ]-Nginx + gunicorn 502 bad gateway

1πŸ‘

βœ…

The problem looks to be with the proxy_pass is passing to a FQDN due to the naming of your up stream.

if (!-f $request_filename) {
    proxy_pass http://rollservice-rostov.ru;
    break;
}

It is passing it straight to that. Change the name of the upstream and you should be okay.

Joe

1πŸ‘

i think it’s Django configuration related:
if you have set DEBUG to False , ALLOWED_HOSTS is used

To allow any domain name

ALLOWED_HOSTS = ['*',]

To allow only your domain name

ALLOWED_HOSTS = ['rollservice-rostov.ru',]

Config file settings.py may look :

...
DEBUG = False
ALLOWED_HOSTS = ['rollservice-rostov.ru',]
...

To include subdomains , add β€œ.” at start

ALLOWED_HOSTS = ['.rollservice-rostov.ru',]

Also , in Django 1.7 and more

ALLOWED_HOSTS = [
   '.rollservice-rostov.ru',  # Allow domain and subdomains
   '.rollservice-rostov.ru.',  # Also allow FQDN and subdomains
]

Check Django docs
https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts

Leave a comment