systemctl staus处于活动状态,但.sock无法连接到上游

时间:2019-12-09 13:50:45

标签: ubuntu nginx flask gunicorn digital-ocean

我正在Degitalocean Ubuntu nginx服务器上运行我的Flask应用程序。我正在使用gunix运行我的应用程序。我已完成此博客中介绍的步骤: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04

但是systemctl status chatleads-nlu说它是活动的:

● chatleads-nlu.service - Gunicorn instance to serve chatleads-nlu
   Loaded: loaded (/etc/systemd/system/chatleads-nlu.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-12-09 11:36:53 UTC; 2h 2min ago
 Main PID: 2428 (gunicorn)
    Tasks: 4 (limit: 2361)
   CGroup: /system.slice/chatleads-nlu.service
           ├─2428 /root/chatleads-nlu/nlu-venv/bin/python3.6 /root/chatleads-nlu/nlu-venv/bin/gunicorn --workers 3 --bind unix:chatleads-nlu.sock -m 007 wsgi:app
           ├─2443 /root/chatleads-nlu/nlu-venv/bin/python3.6 /root/chatleads-nlu/nlu-venv/bin/gunicorn --workers 3 --bind unix:chatleads-nlu.sock -m 007 wsgi:app
           ├─2444 /root/chatleads-nlu/nlu-venv/bin/python3.6 /root/chatleads-nlu/nlu-venv/bin/gunicorn --workers 3 --bind unix:chatleads-nlu.sock -m 007 wsgi:app
           └─2445 /root/chatleads-nlu/nlu-venv/bin/python3.6 /root/chatleads-nlu/nlu-venv/bin/gunicorn --workers 3 --bind unix:chatleads-nlu.sock -m 007 wsgi:app

Dec 09 11:36:53 CHATLEADS-NLP systemd[1]: Started Gunicorn instance to serve chatleads-nlu.
Dec 09 11:36:53 CHATLEADS-NLP gunicorn[2428]: [2019-12-09 11:36:53 +0000] [2428] [INFO] Starting gunicorn 20.0.4
Dec 09 11:36:53 CHATLEADS-NLP gunicorn[2428]: [2019-12-09 11:36:53 +0000] [2428] [INFO] Listening at: unix:chatleads-nlu.sock (2428)
Dec 09 11:36:53 CHATLEADS-NLP gunicorn[2428]: [2019-12-09 11:36:53 +0000] [2428] [INFO] Using worker: sync
Dec 09 11:36:53 CHATLEADS-NLP gunicorn[2428]: [2019-12-09 11:36:53 +0000] [2443] [INFO] Booting worker with pid: 2443
Dec 09 11:36:53 CHATLEADS-NLP gunicorn[2428]: [2019-12-09 11:36:53 +0000] [2445] [INFO] Booting worker with pid: 2445
Dec 09 11:36:53 CHATLEADS-NLP gunicorn[2428]: [2019-12-09 11:36:53 +0000] [2444] [INFO] Booting worker with pid: 2444
Dec 09 11:36:54 CHATLEADS-NLP gunicorn[2428]: [2019-12-09 11:36:54]: 2443 INFO Starting app in production environment
Dec 09 11:36:54 CHATLEADS-NLP gunicorn[2428]: [2019-12-09 11:36:54]: 2444 INFO Starting app in production environment
Dec 09 11:36:54 CHATLEADS-NLP gunicorn[2428]: [2019-12-09 11:36:54]: 2445 INFO Starting app in production environment

但是sudo less /var/log/nginx/error.log说它无法连接到上游:

2019/12/10 06:38:10 [crit] 3042#3042: *1075 connect() to unix:/root/chatleads-nlu/chatleads-nlu.sock failed (13: Permission denied) while connecting to upstream, client: 27.147.155.252, server: nlp.chatleads.io, request: "GET / HTTP/1.1", upstream: "http://unix:/root/chatleads-nlu/chatleads-nlu.sock:/", host: "nlp.chatleads.io:8888"
2019/12/10 06:38:10 [error] 3042#3042: *1075 open() "/usr/share/nginx/html/50x.html" failed (2: No such file or directory), client: 27.147.155.252, server: nlp.chatleads.io, request: "GET / HTTP/1.1", upstream: "http://unix:/root/chatleads-nlu/chatleads-nlu.sock/", host: "nlp.chatleads.io:8888"


这是我的/etc/nginx/sites-available/digitalocean

server {
        listen 8888;
        listen [::]:8888;
        server_name nlp.chatleads.io www.nlp.chatleads.io;
        # root /var/www/html;
        # index index.html index.htm;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        # try_files $uri $uri/ =404;
        proxy_pass http://unix:/root/chatleads-nlu/chatleads-nlu.sock;
        # proxy_pass http://127.0.0.1:5151;
        proxy_http_version 1.1;
        proxy_read_timeout 300;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        # Uncomment to enable naxsi on this location
        # include /etc/nginx/naxsi.rules
        }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        proxy_pass http://localhost:5151;
    }
}

这已链接到/etc/nginx/sites-enabled

这是我的应用程序文件的权限:

-rw-r--r-- 1 root root      717 Dec  9 05:33 README.md
drwxr-xr-x 2 root root     4096 Dec  9 10:19 __pycache__
drwxr-xr-x 6 root root     4096 Dec  9 06:07 app
srwxrwxr-- 1 root www-data    0 Dec  9 11:36 chatleads-nlu.sock
-rw-r--r-- 1 root root      394 Dec  9 05:33 config.py
drwxr-xr-x 6 root root     4096 Dec  9 05:33 nlu-venv
-rw-r--r-- 1 root root      544 Dec  9 05:33 requirements.txt
-rw-r--r-- 1 root root       88 Dec  9 10:15 wsgi.py

我几乎尝试了所有方法,但无法找出问题所在。 任何帮助将不胜感激。

0 个答案:

没有答案