0

在解决这个问题之前,我想说明我被这个 502 页面困了两天,需要帮助,我让我的应用程序在数字海洋水滴上完美运行,我决定向它添加另一个应用程序,现在没有人在运行(502 错误)我删除了第二个应用程序,但第一个应用程序没有重新启动

我运行的命令和结果

sudo systemctl status nginx -> 活动:活动(运行)

● gunicorn.service - gunicorn daemon
     Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-01-12 09:57:21 UTC; 35min ago
TriggeredBy: ● gunicorn.socket
   Main PID: 1031544 (gunicorn)
      Tasks: 4 (limit: 1136)
     Memory: 168.5M
     CGroup: /system.slice/gunicorn.service
             ├─1031544 /home/taki/kahraba/venv/bin/python3 /home/taki/kahraba/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock config.wsgi:application
             ├─1031556 /home/taki/kahraba/venv/bin/python3 /home/taki/kahraba/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock config.wsgi:application
             ├─1031557 /home/taki/kahraba/venv/bin/python3 /home/taki/kahraba/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock config.wsgi:application
             └─1031558 /home/taki/kahraba/venv/bin/python3 /home/taki/kahraba/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock config.wsgi:application

sudo nginx -t -> 语法没问题我得到的唯一错误是运行时

须藤尾巴 -100 /var/log/nginx/error.log

connect() to unix:/run/gunicorn.sock failed (111: Connection refused) while connecting to upstream, client: xx-xx-xx-xx server : xx-xx-xx-xx , upstream: "http://unix:/run/gunicorn.sock:/"


当我使用sudo ufw allow 8000允许 port:8000并且我运行
gunicorn --bind 0.0.0.0:8000 config.wsgi 时,我的应用程序运行没有错误

我必须提供我的 gunicorn 配置吗?我还删除了默认的 nginx 配置文件这是我的 nginx 文件

server {

    listen 80 default_server;
    listen [::]:80 default_server;
    server_name IP_ADRESS;
    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/taki/kahraba/kahraba;
    }

    location /media/ {
        root /home/taki/kahraba/kahraba;
    }
    location /assets/ {
        root /home/taki/kahraba/kahraba;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
        try_files $uri $uri/ =404;
   }
} 

我不小心删除了 ngix.conf 文件我有另一个液滴我复制了 nginx.conf 文件并将它传递给这个液滴它是

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##
        client_max_body_size 20M;
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        #
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

如果有人可以帮忙请!

谢谢你

4

0 回答 0