ERR_CONNECTION_REFUSED 我无法连接我的 Ubuntu 服务器

ERR_CONNECTION_REFUSED 我无法连接我的 Ubuntu 服务器

我有一台 Ubuntu 服务器,用于为 Django 项目提供服务。但我无法浏览任何内容。我ERR_CONNECTION_REFUSED在所有浏览器上都遇到错误。

服务器主机、操作系统和应用程序:

  • 数字海洋 Ubuntu 18.04 (LTS) x64
  • nginx 版本:nginx/1.14.0(Ubuntu)
  • ufw 0.36

这是我的 nginx 和 ufw 配置:

$ systemctl status nginx

● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled
   Active: active (running) since Thu 2021-03-25 11:31:11 UTC; 5h 21min ago
     Docs: man:nginx(8)  Main PID: 18638 (nginx)
    Tasks: 2 (limit: 1152)    CGroup: /system.slice/nginx.service
           ├─18638 nginx: master process /usr/sbin/nginx -g daemon on; master_pr
           └─18643 nginx: worker process

$ sudo ufw status

Nginx Full                 ALLOW       Anywhere                  
22/tcp                     ALLOW       Anywhere                  
Nginx HTTP                 ALLOW       Anywhere                  
80/tcp                     ALLOW       Anywhere                  
443/tcp                    ALLOW       Anywhere                  
21/tcp                     ALLOW       Anywhere                  
25/tcp                     ALLOW       Anywhere                  
Nginx Full (v6)            ALLOW       Anywhere (v6)             
22/tcp (v6)                ALLOW       Anywhere (v6)             
Nginx HTTP (v6)            ALLOW       Anywhere (v6)             
80/tcp (v6)                ALLOW       Anywhere (v6)             
443/tcp (v6)               ALLOW       Anywhere (v6)             
21/tcp (v6)                ALLOW       Anywhere (v6)             
25/tcp (v6)                ALLOW       Anywhere (v6)

nginx 站点启用配置文件

server {
   listen 80;
   server_name 188.166.117.124;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/ahubelkis/personal_web_site/personal_web_site;
    }

    location /media/ {
        root /home/ahubelkis/personal_web_site/personal_web_site;
    }

    location / {
        include /etc/nginx/proxy_params;
        proxy_pass http://unix:/home/ahubelkis/personal_web_site/personal_web_site/personal_web_site.sock;
    }
}

$ sudo systemctl restart nginx

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

我的配置有什么问题。

答案1

对您的 IP 进行端口扫描(从您的 nginx 配置中收集)表明该主机上唯一开放的端口是 22。

也许可以尝试暂时禁用 UFW sudo ufw disable,然后看看是否可以连接?

相关内容