托管网站时出现以下问题。我在这里配置了所有.conf文件:
gunicorn.service
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=user
Group=nginx
WorkingDirectory=/root/myproject
ExecStart=/root/myproject/myprojectenv/bin/gunicorn --workers 3 --bind
unix:/root/myproject/myproject.sock myproject.wsgi:application
[Install]
WantedBy=multi-user.target
和我的nginx.conf
server {
listen 80;
server_name agros.uz www.agros.uz;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /root/myproject/;
}
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://unix:/root/myproject/myproject.sock;
}
}
但是我遇到以下错误
unix:/root/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 37.9.113.208, server: agros.uz, request: "GET /uz/insurance?type=physical&page=2&page=7&page=6&page=8&page=4 HTTP/1.1", upstream: "http://unix:/root/myproject/myproject.sock:/uz/insurance?type=physical&page=2&page=7&page=6&page=8&page=4", host: "agros.uz"
当我访问域时,发生此错误502 Bad Gateway
错误
并且没有在/root/myproject/myproject.sock
文件中提到的在gunicorn.service
中创建.sock文件。