nginx 不会在某些端口上响应

nginx won't respond on some ports

我的问题是我无法将另一个端口添加到我现有的 nginx 配置中。 我已经使用以下命令禁用了 ubuntu 服务器上的防火墙:

sudo service ufw stop

在可用站点中,我将此文件命名为 file.conf:

server {
listen 80;
server_name example.com example.com;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
    root /home/user/project;
}

location /files/ {
    root /home/user/download/;
}
}
server{
    listen 8080;
    server_name example.com www.example.com;
        location / {
    include         uwsgi_params;
    uwsgi_pass      unix:/run/uwsgi/project.sock;
}
}
server{
    listen 8001;
    server_name example.com www.example.com;

location / {
    include         uwsgi_params;
    uwsgi_pass      unix:/run/uwsgi/project.sock;
}
}

我之前有 8080 部分,这在过去和现在都有效,但 8001 不工作。我禁用了防火墙,所以我认为问题出在其他地方。

我也运行这个命令:

 sudo netstat -napl | grep 8001

它返回了这个:

tcp        0      0 0.0.0.0:8001            0.0.0.0:*               LISTEN      3475/nginx -g daemo

感谢您的帮助和支持

我已经解决了这个问题! 问题是我将 cloudflare 用于 dns,而 cloudflare 只允许我使用此处列出的一些端口:

对于通过 HTTP 发出的请求:

80 8080 8880 2052 2082 2086 2095

对于通过 HTTPS 发出的请求:

443 2053 2083 2087 2096 8443

希望它能帮助其他一些面临这个问题的人!