讓你的網站秒配 HTTPS 證書

原諒我當一次標題黨 python

網站爲何要配置 HTTPS,以及配置 HTTPS 有什麼優勢就再也不解釋了,咱們直奔主題,使用 Certbot 工具讓你的網站秒配 HTTPS 證書。nginx

Certbot

介紹

Certbot is an easy-to-use client that fetches a certificate from Let’s Encrypt—an open certificate authority launched by the EFF, Mozilla, and others—and deploys it to a web server.
Certbot是由 Let’s Encrypt 一個開放免費證書頒發機構的EFF、Mozilla和其餘開發者推出的,易於客戶端獲取網站加密證書。 自嘲:英語翻譯的好爛(^o^)web

特色

  • 簡單易用、免費
  • 自動化配置
  • 證書無限免費續簽
  • 效率極高,一次安裝,再配置其餘站點 https 證書只須要 3 分鐘

PS: 由於測試服務器站點過多,每次使用 acme-tiny 腳本配置證書都要十多分鐘時間,爲了提升效率,就使用了 Let's Encrypt 官網推薦的自動部署腳本。服務器

官方網站: https://certbot.eff.orgsession

certbot官方網站.png

  1. 選擇本身的服務器和操做系統環境,Certbot 官方會給出詳細的安裝過程和使用方法,個人環境是 Nginx + Ubuntu 14.04,安裝過程以下
$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install python-certbot-nginx

安裝成功以後把 certbot 加入系統全局變量 PATH 中。dom

  1. 獲取證書前須要先中止 Nginx 服務

service nginx stop工具

  1. 生成單域名證書

certbot certonly --standalone --email your@email.com -d yourdomain.com測試

一次生成多域名證書:fetch

certbot certonly --standalone --email your@email.com -d yourdomain.com -d yourdomain2.com網站

證書配置成功後提示:
image.png

4.查看網站生成的證書

tree /etc/letsencrypt/live/

5.配置 Nginx

…… 其餘配置

    listen 443 ssl;

    ssl_certificate   /etc/letsencrypt/live/{yourdomain}.com/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/{yourdomain}.com/privkey.pem;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

6.重啓 Nginx

service nginx start

此時再加上 https:// 訪問你的網站,就會有一把可愛別緻的小綠鎖 Secure^_^

Let’s Encrypt 生成的免費證書爲3個月時間,使用 certbot renew 能夠無限免費續簽 Https 證書

certbot renew

  • 在生成證書的時候遇到一個問題
    Problem binding to port 443: Could not bind to IPv4 or IPv6.. Skipping

這是由於 nginx 服務沒有關閉,執行 service nginx stop 便可。

以爲有用是否是該點贊呢?

相關文章
相關標籤/搜索