<address id="r9vd9"><address id="r9vd9"><listing id="r9vd9"></listing></address></address>

      歡迎您光臨深圳塔燈網絡科技有限公司!
      電話圖標 余先生:13699882642

      網站百科

      為您解碼網站建設的點點滴滴

      certbot配置網站SSL安全證書

      發表日期:2018-12 文章編輯:小燈 瀏覽次數:5082

      總覺得寫個文章應該有個起承轉合是吧,那就講一下起因吧,老夫發現postman不能測試接口了。。。好吧我選擇了最麻煩的一個解決方法,也算是閑的蛋疼。

      正文

      第一步當然是下載安裝

       $ wgethttps://dl.eff.org/certbot-auto$ chmod a+x ./certbot-auto$ ./certbot-auto

      這個小工具會自動下載并安裝相關依賴和 Python 包。稍等一下就完成了。

      第二部生成證書

      生成證書過程中需要鑒權。有多種方式,比如webroot、standalone、apache、nginx、manual等。我使用過前兩種。 這兩種中,簡單一點的是standalone。不過,這種方式需要把現有的 WebServer 停掉,因為這種方式下 certbot 需要占用 80 端口。

      # ./certbot-auto certonly --text --agree-tos --email webmaster@example.com --standalone -d example.com -d www.example.com -d service.example.com 

      -d參數指定域名,可多個。一般第一個是主域名。

      webroot方式稍微繁瑣一些,但好處是不需要關?,F有的 WebServer 。此方法需要在域名對應的根目錄下新建.well-known目錄并寫入若干文件供驗證服務訪問。 因此需要配置 WebServer 允許外部訪問http://example.com/.well-known路徑。配置方法請參考相應 WebServer 的文檔。Nginx 的默認配置應該不用修改,Apache 就不知道了。 另外,不同的域名的根路徑可能不同,下面的例子中可以看到為不同的域名指定不同的根路徑。

      # ./certbot-auto certonly --text --agree-tos --email webmaster@excample.com --webroot -w /var/www/example -d example.com -d www.example.com -w /var/service/example -d service.ulefa.com 

      無論使用那種方式,運行以上命令后都會在/etc/letsencrypt生成一堆東西,包括證書。

      第三步修改Nginx 配置以提供 HTTPS 服務

      打開 Nginx 的配置文件(默認為:/etc/nginx/nginx.conf),在需要提供 HTTPS 的server下新增以下三行,并把listen 80;刪掉:

      ssl_certificate /etc/letsencrypt/live/api.bqtabc.adflash.cn/fullchain.pem;ssl_certificate_key/etc/letsencrypt/live/api.bqtabc.adflash.cn/privkey.pem;ssl_session_timeout 5m;ssl_protocols SSLv2 SSLv3 TLSv1;ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;ssl_prefer_server_ciphers on; 

      新增以下server使所有 HTTP 請求都跳轉至 HTTPS :

      server {listen80;server_name example.com www.example.com service.example.com;return301 https://$host$request_uri;} 

      最后定期 renew

      Let's Encrypt 的證書有效期為 90 天,所以需要在到期前 renew 一下證書。 使用以下命令即可。

      # ./certbot-auto renew --text --agree-tos --email webmaster@excample.com --webroot -w /var/www/example -d example.com -d www.example.com -w /var/service/example -d service.ulefa.com 

      或者直接運行以下命令,此時 certbot 會使用默認參數(此例為:/etc/letsencrypt/renewal/example.com.conf):

      # ./certbot-auto renew 

      又或者在crontab里加入定時任務,每隔 80 天的凌晨 4 點執行一次 renew:

      04 */80 * * /path/to/certbot-auto renew &>> /dev/null 

      本頁內容由塔燈網絡科技有限公司通過網絡收集編輯所得,所有資料僅供用戶學習參考,本站不擁有所有權,如您認為本網頁中由涉嫌抄襲的內容,請及時與我們聯系,并提供相關證據,工作人員會在5工作日內聯系您,一經查實,本站立刻刪除侵權內容。本文鏈接:http://www.webpost.com.cn/20539.html
      相關開發語言
       八年  行業經驗

      多一份參考,總有益處

      聯系深圳網站公司塔燈網絡,免費獲得網站建設方案及報價

      咨詢相關問題或預約面談,可以通過以下方式與我們聯系

      業務熱線:余經理:13699882642

      Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.    

      国产成人精品综合在线观看