HTTPS:// 在 Nginx 上不起作用

HTTPS:// 在 Nginx 上不起作用

我的域名是:http://indiasaplings.com/

我运行了这个命令:sudo certbot --nginx -d indiasaplings.com -d www.indiasaplings.com

它产生了这样的输出:

IMPORTANT NOTES:

Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/indiasaplings.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/indiasaplings.com/privkey.pem
Your cert will expire on 2019-12-29. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the “certonly” option. To non-interactively renew all of
your certificates, run “certbot renew”
  • 内容管理系统:Mazento 2
  • Web 服务器:Nginx
  • 操作系统:Ubuntu 18.04
  • 托管:AWS

这是我的服务器块:-

server {
   # if ($host = indiasaplings.com) {
    #    return 301 https://$host$request_uri;
   # } # managed by Certbot


    listen 80;
    server_name indiasaplings.com www.indiasaplings.com;
   # return 301 https://indiasaplings.com$request_uri;
    set $MAGE_ROOT /var/www/html/sm/sm_shopee;
    set $MAGE_DEBUG_SHOW_ARGS 1;
    include /etc/nginx/m2/m231.conf;


}

server {
    listen 443 ssl;
    server_name indiasaplings.com www.indiasaplings.com;
  # return 301 https://indiasaplings.com$request_uri;
    set $MAGE_ROOT /var/www/html/sm/sm_shopee;
    set $MAGE_DEBUG_SHOW_ARGS 1;
    include /etc/nginx/m2/m231.conf;
    ssl_certificate /etc/letsencrypt/live/indiasaplings.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/indiasaplings.com/privkey.pem; # managed by Certbot


}

server {
    listen              443 ssl default_server;
    listen              [::]:443 ssl default_server;
    server_name         indiasaplings.com www.indiasaplings.com;
    set $MAGE_ROOT /var/www/hmtl/sm/sm_shopee;
    set $MAGE_DEBUG_SHOW_ARGS 1;
   include /etc/nginx/m2/m231.conf;

    }

即使安装并配置了 Let's Encrypt,我也无法在 HTTPS:// 上打开我的网站。请指导,谢谢!

答案1

您有两个服务器块,其中既有listen 443也有server_name indiasaplings.com。其中一个已配置证书文件,而另一个缺少证书文件。删除没有证书文件的 443 块。

相关内容