B
B
Blacker862016-09-17 13:04:46
Python
Blacker86, 2016-09-17 13:04:46

Nginx + Gunicorn + Pyramid output static on port 8000 instead of 80, how to fix?

Good day to all!
Installed nginx, gunicorn, pyramid framework on vds.
nginx settings file (/etc/nginx/sites-available/default):

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    access_log  /var/log/nginx/myproject.log;

    location /static/ {
        root /root/myproject/appname/appname;
        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;
    }
  }

I launch Gunicorn with the command:
gunicorn --paste development.ini -b :8000
As a result, at http://[site_name].ru the site loads without static, but at http://[site_name].ru:8000 the site loads normally . In this case, links in the source code of the page in the first case look like href="http://127.0.0.1:8000/static/file.png", and in the second case href="http://[site_name].ru:8000/static/file.png". Before that, there was a Bottle Framework with the same nginx settings and everything worked fine. How to fix this situation?
Kick, please, in the right direction.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question