首页 > 解决方案 > 502 Bad Gateway nginx 服务器

问题描述

我正在按照 satssehgal 教程在云服务器上托管网站。

不幸的是,我得到了一个 502 Bad Gateway。

这是我的 nginx/error.log

2021/06/25 12:18:58 [crit] 2494#2494: *1 connect() to unix:/home/seast/blog/blog.sock failed (13: Permission denied) while connecting to upstream, client: 85.68.32.122, server: 139.162.255.54, request: "GET / HTTP/1.1", upstream: "http://unix:/home/seast/blog/blog.sock:/", host: "139.162.255.54"
2021/06/25 12:19:07 [crit] 2494#2494: *3 connect() to unix:/home/seast/blog/blog.sock failed (13: Permission denied) while connecting to upstream, client: 85.68.32.122, server: 139.162.255.54, request: "GET / HTTP/1.1", upstream: "http://unix:/home/seast/blog/blog.sock:/", host: "139.162.255.54"
2021/06/25 12:19:08 [crit] 2519#2519: *1 connect() to unix:/home/seast/blog/blog.sock failed (13: Permission denied) while connecting to upstream, client: 85.68.32.122, server: 139.162.255.54, request: "GET / HTTP/1.1", upstream: "http://unix:/home/seast/blog/blog.sock:/", host: "139.162.255.54"
2021/06/25 12:19:10 [crit] 2519#2519: *1 connect() to unix:/home/seast/blog/blog.sock failed (13: Permission denied) while connecting to upstream, client: 85.68.32.122, server: 139.162.255.54, request: "GET / HTTP/1.1", upstream: "http://unix:/home/seast/blog/blog.sock:/", host: "139.162.255.54"
2021/06/25 12:20:58 [crit] 2519#2519: *5 connect() to unix:/home/seast/blog/blog.sock failed (13: Permission denied) while connecting to upstream, client: 85.68.32.122, server: 139.162.255.54, request: "GET /admin HTTP/1.1", upstream: "http://unix:/home/seast/blog/blog.sock:/admin", host: "139.162.255.54"
2021/06/25 12:21:03 [crit] 2519#2519: *5 connect() to unix:/home/seast/blog/blog.sock failed (13: Permission denied) while connecting to upstream, client: 85.68.32.122, server: 139.162.255.54, request: "GET /polls HTTP/1.1", upstream: "http://unix:/home/seast/blog/blog.sock:/polls", host: "139.162.255.54"
2021/06/25 12:26:04 [crit] 2519#2519: *9 connect() to unix:/home/seast/blog/blog.sock failed (13: Permission denied) while connecting to upstream, client: 80.82.77.192, server: 139.162.255.54, request: "GET / HTTP/1.1", upstream: "http://unix:/home/seast/blog/blog.sock:/", host: "139.162.255.54"
2021/06/25 12:31:57 [crit] 2519#2519: *11 connect() to unix:/home/seast/blog/blog.sock failed (13: Permission denied) while connecting to upstream, client: 85.68.32.122, server: 139.162.255.54, request: "GET / HTTP/1.1", upstream: "http://unix:/home/seast/blog/blog.sock:/", host: "139.162.255.54"

nginx/站点可用/博客

  GNU nano 5.4         /etc/nginx/sites-available/blog
    server {
        listen 80;
        server_name 139.162.255.54;
        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
            root /home/seast/blog;
        }
        location / {
            include proxy_params;
            proxy_pass http://unix:/home/seast/blog/blog.sock;
        }
    }

GNU nano 5.4 /etc/systemd/system/gunicorn.service

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

[Service]
User=seast
Group=www-data
WorkingDirectory=/home/seast/blog
ExecStart=/home/seast/venv/bin/gunicorn --access-logfile - --workers 3 ->

[Install]
WantedBy=multi-user.target

标签: djangonginx

解决方案


推荐阅读