Nginx

在 Ubuntu 伺服器上使用 Nginx 配置 SSL

  • October 30, 2022

我一直在線上學習一些教程,並且已經啟動並執行了我的燒瓶應用程序。我添加了域名,它們可以正常工作。但是,現在我嘗試使用 Certbot 為 nginx 獲取 SSL 證書。

這是命令,因為我已經創建了證書。


certbot install --cert-name domainname.com

我不斷收到錯誤:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Deploying certificate
Could not install certificate
Could not automatically find a matching server block for wehavetheleads.org. Set the `server_name` directive to use the Nginx installer.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

這是我的 etc/nginx/sites_enabled 配置文件:

server {
       listen 80;
       server_name <public-server-ip>;

       location / {
               proxy_pass http://127.0.0.1:8000;
               proxy_set_header Host $host;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

       }
}

server_name需要包含服務的域名,而不是 IP 地址。

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