S
S
Sanya Hihi Haha2020-04-26 12:39:08
Nginx
Sanya Hihi Haha, 2020-04-26 12:39:08

How to properly configure nginx to run a django project on vds?

Here is the config file sites-availabel/default

server {
    listen 80;
    server_name 194.87.110.108; #либо ip, либо доменное имя
    access_log  /var/log/nginx/example.log;

    location /static/ {
        root /opt/myenv/myproject/;
        expires 30d;
    }

    location / {
        proxy_pass http://127.0.0.1:8000; 
        proxy_set_header Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
  }

194.87.110.108 - ip

in settings.py The django project itself and venv are located at home/valinor/project/mewar/ Tried running ./manage.py runserver 0.0.0.0:8000 Tried ./manage.py runserver Nothing helps, I as I understand the problem in the nginx config, but I still haven’t found a solution after a day
ALLOWED_HOSTS = ['194.87.110.108']

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Karasik, 2020-04-26
@vitaly_il1

As far as I understand it is necessary
1) in gunicorn --bind 127.0.0.1:8000
2) ALLOWED_HOSTS = ['127.0.0.1']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question