ufw 端口可在本地访问,但无法远程访问

ufw 端口可在本地访问,但无法远程访问

我正在尝试访问我的服务器上在端口 8000 上运行的应用程序。从服务器,我可以通过curl mydomainname.com:8000我刚刚获得的任何其他机器访问该应用程序curl: (7) Failed to connect to mydomainname.com port 8000: Connection refused

我究竟做错了什么?

这是 ufw 和 netstat 的输出。

$ sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
22                         ALLOW IN    Anywhere
80/tcp                     ALLOW IN    Anywhere
8000                       ALLOW IN    Anywhere
22 (v6)                    ALLOW IN    Anywhere (v6)
80/tcp (v6)                ALLOW IN    Anywhere (v6)
8000 (v6)                  ALLOW IN    Anywhere (v6)

$ netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8000            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 :::25                   :::*                    LISTEN

答案1

看起来您的 Nginx 主机没有设置为监听端口 8000。您的虚拟主机文件允许什么?

即您/etc/nginx/sites-available/mydomainname.com.config在其配置中允许什么?

这是一个示例配置,listen您的配置中该行是什么意思?

server {
        listen   80; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6only=on; ## listen for ipv6

        root /var/www/example.com/public_html;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name example.com;
}

相关内容