简体   繁体   English

Django + gunicorn + nginx网站在使用example.com:8000时运行完美,但在使用example.com时却运行不完美

[英]Django+gunicorn+nginx site runs perfect when using example.com:8000 but not when using example.com

I have a site on Digital Ocean VPS. 我在Digital Ocean VPS上有一个网站。 But I get a bad gateway when accessing example.com but not when example.com:8000 . 但是,我得到一个坏网关访问时example.com而不是当example.com:8000

Also when visiting the django-admin at example.com:8000/admin the default formatting is not coming. 同样,在example.com:8000/admin访问django-admin时,默认格式不会出现。 I guess nginx is not being able to serve the static content. 我猜nginx无法提供静态内容。

Below is the service file for gunicorn: 以下是gunicorn的服务文件:

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

[Service]
Group=www-data
WorkingDirectory=/FINlit
ExecStart=/FINlit/venvforfinlit/bin/gunicorn --access-logfile - --workers 3 --bind unix:/FINlit/Finlit.sock Finlit.wsgi:application

[Install]
WantedBy=multi-user.target

and the nginx config: 和Nginx配置:

server {
    listen 80;
    server_name my_ip;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /FINlit;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/FINlit/Finlit.sock;
    }
}

Thanks 谢谢

After almost searching for a couple of hours, my instincts led me to replace the IP with the domain name in the nginx config and now it works fine. 经过几乎几个小时的搜索,我的直觉使我用nginx配置中的域名替换了IP,现在可以正常工作了。 Actually I don't know, there might be a possibility that something else did the job for me but anyways. 其实我不知道,可能还有其他事情为我完成了工作,但是无论如何。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM