Ubuntu

HTTPS:// 不適用於 Nginx

  • January 15, 2021

我的域名是: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
  • 網路伺服器: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:// 上打開我的網站。請指導,謝謝!

您有兩個帶有listen 443和的伺服器塊server_name indiasaplings.com。一個配置了證書文件,第二個缺少它們。刪除沒有證書文件的 443 塊。

引用自:https://serverfault.com/questions/986203