2020年5月24日 星期日

[SSL] ZeroSSL 申請免費 Certificate 並設置 Nginx


ZeroSSL (https://zerossl.com/) 主要也是透過 let's encrypt (https://letsencrypt.org/) 去申請,因此也僅有90天的效期,會感覺特地用這個平台有點多餘,但整體介面較美觀,並且也比官方的流程好申請。




1. 輸入你的 domain



2. 申請帳號


3. 選擇方案


4. 驗證 domain 所有權


這邊選擇上傳檔案的方式,下載 Auth File 後,放置於 web server,必須要放置成指定的外連路徑。

假設 domain 為 myweb.com ,
那麼檔案就必須放置於 http://myweb.com/well-known/pki-validation/xxx.txt
以 nginx 為例,便是 /html/well-known/pki-validation/xxx.txt


5. 下載 CA



壓縮檔內會有三個檔案



6. 於 nginx 中設置 ssl

編輯  /etc/nginx/conf.d/default.conf

加入:
listen   443 ssl;
ssl_certificate /ca/certificate.crt;
ssl_certificate_key /ca/private.key;

記得 crt 跟 key 檔案要改成自己的路徑


設定完成後如下:
server {
    listen       80;
    listen   443 ssl;

    server_name  localhost;

    ssl_certificate /ca/certificate.crt;
    ssl_certificate_key /ca/private.key;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

}


7. 重新啟動 nginx

service nginx reload

完成,訪問你的 https  網站









沒有留言:

張貼留言