在 nginx 中通过 certbot 安装 ssl 证书后网站关闭

Edw*_*ese 4 ssl https backend nginx certbot

下面是我的 nginx 配置。我修改了“默认”文件(位于“可用站点”)。当通过“http”时我能够访问该网站。但是当我尝试通过“https”时,连接超时并且无法访问该页面。奇怪的是,Nginx 没有在日志中记录任何条目(access.log 和 error.log)。我正在寻求帮助,因为我对此完全陌生。

# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.

##

# Default server configuration
#
server {
    listen 80;
    listen [::]:80;

    root /var/www/main.x.com/html;

    
    index index.html

    server_name main.x.com;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }

}


server {
    listen 443 ssl;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_certificate /etc/letsencrypt/live/main.x.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/main.x.com/privkey.pem;

    server_name main.x.com;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    location / {
        root /var/www/main.x.com/html;
        index index.html;
    }
}
Run Code Online (Sandbox Code Playgroud)

Edw*_*ese 10

在aws ec2中打开443端口

经过两天无休无止的调试,我明白了问题所在。我没有在EC2安全组中打开443端口。无论遇到类似问题,请记住以下事项 -> 确保您的操作系统防火墙允许通过 443 进行连接,同时确保您的实例允许通过 443 进行连接。

在此输入图像描述