Nginx 不会监听 443,即使 netstat 说它监听

Nginx 不会监听 443,即使 netstat 说它监听

我在一台服务器上安装了 SSL,一切顺利,就像我之前在其他服务器上安装的那样,但是这个就是不起作用,我检查了一下sudo netstat -t -l -p -n 我得到了这个:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1062/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2560/exim
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      3129/nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      3129/nginx

但当我尝试访问该网站时,连接超时,现在如果我检查https://www.yougetsignal.com/tools/open-ports/对于端口 443,它会说端口已关闭。Nginx -t 没有返回任何错误。

sudo iptables -L 显示:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

sudo ufw status 显示:

Status: inactive

我的 default.vhost 文件:

server {
    listen       80 default_server;
    # listen       [::]:80 default_server;
    server_name  _;
    root         /jet/app/www/website/public;

    index index.php index.html index.htm;
    autoindex on;

    # Load configuration files for the default server block.
    include /jet/etc/nginx/conf.d/*.inc;

#location / {
           try_files $uri $uri/ /index.php;
#    }

   location ~ \.php$ {
       #try_files $uri /index.php =404;
       try_files $uri =404;
       fastcgi_split_path_info ^(.+\.php)(/.+)$;
       fastcgi_pass unix:/var/run/php5-fpm.sock;
       fastcgi_index index.php;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       include fastcgi_params;
   }

}


server {
    listen       443 default_server;

    ssl on;
    ssl_certificate /jet/etc/nginx/SSL/website.crt;
    ssl_certificate_key /jet/etc/nginx/SSL/private/website.key;


    server_name  _;
    root         /jet/app/www/website/public;




    index index.php index.html index.htm;
    autoindex on;

    # Load configuration files for the default server block.
    include /jet/etc/nginx/conf.d/*.inc;

#location / {
           try_files $uri $uri/ /index.php;
#    }

   location ~ \.php$ {
       #try_files $uri /index.php =404;
       try_files $uri =404;
       fastcgi_split_path_info ^(.+\.php)(/.+)$;
       fastcgi_pass unix:/var/run/php5-fpm.sock;
       fastcgi_index index.php;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       include fastcgi_params;
   }




}

到底发生什么事了?

答案1

转到 EC2 仪表板并单击“安全组”。选择与您的实例相关的安全组并添加以下行

HTTP        tcp        443       443        0.0.0.0/0

来源 : 在 Amazon AWS 中设置 Apache

相关内容