【发布时间】:2018-01-02 18:59:55
【问题描述】:
我在 Digital Ocean VPS 上有一个网站。
但是在访问example.com 时我的网关不好,但在example.com:8000 时却没有。
另外,当访问example.com:8000/admin 的 django-admin 时,默认格式不会出现。我猜 nginx 无法提供静态内容。
下面是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
和 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;
}
}
谢谢
【问题讨论】:
-
upstream app_server_wsgiapp块的意义何在?你没有代理任何东西。 127.0.0.1:8000 上运行的是什么? -
即使删除了块,也没有区别。
-
我没有说它会解决问题(否则我会把它作为答案而不是评论),只是想知道它的用途。您确定 gunicorn 正在运行并且可以写入该套接字吗? gunicorn、nginx 或 systemd 的日志中是否有任何消息?
-
感谢@DanielRoseman,但是用域名替换IP,不知何故成功了。
-
我还根据您的建议编辑了配置文件。谢谢。
标签: django nginx gunicorn digital-ocean