<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 使用 Certbot 向 Let's Encrypt 免費申請 HTTPS 證書 2019-09-29[8](https://www.zmrenwu.com/courses/hellodjango-blog-tutorial/materials/76/#comment-area)1375 HTTP 報文以明文形式傳輸,如果你的網站只支持 HTTP 協議,那么就有可能遭受到安全攻擊。你可以使用 Google 瀏覽器打開一個 HTTP 協議網站,會發現 Chrome 在網址的左邊將這個網站標記為不安全。 HTTPS 為 HTTP 報文提供了一個加密傳輸的通道,這樣攻擊者就無法竊聽或者篡改傳輸的內容。要啟用 HTTPS,必須向一個可信任機構申請一個 HTTPS 證書。專業的證書申請需要收費,不過對于個人博客網站來說,有很多免費的證書申請機構。比如 Let’s Encrypt,它提供了免費的證書申請服務,申請過程十分簡單,只需要運行幾條命令即可,而且證書到期后支持自動續期,可謂一勞永逸。接下來我們就是用 Let’s Encrypt 提供的工具來申請免費的 https 證書。 首先安裝 Let’s Encrypt 提供的證書申請工具。登錄[https://certbot.eff.org/](https://certbot.eff.org/),選擇我們博客網站使用的服務器軟件和操作系統。教程中以 Nginx 和 CentOS 7 為例: 首先安裝必要工具: ~~~bash $ sudo yum -y install yum-utils$ sudo sudo yum install -y certbot python2-certbot-nginx ~~~ certbot python2-certbot-nginx 是 Let’s Encrypt 提供的 HTTPS 證書申請的工具,python2-certbot-nginx 是專門針對 Nginx 的插件,使得 Nginx 運行的服務申請證書更加簡單方便。 然后運行證書申請命令: ~~~bash $ sudo certbot --nginx ~~~ > 注意 > > 經測試,運行上述命令后有可能報 ImportError: No module named 'requests.packages.urllib3' 的錯誤,這是由于 requests 和 urlib3 版本過低所致(可以參考這個[issue](https://github.com/certbot/certbot/issues/5104)的討論),解決辦法是重裝它們,運行下面的命令: > > `bash $ pip uninstall requests $ pip uninstall urllib3 $ yum remove python-urllib3 $ yum remove python-requests` > > 然后重新安裝 certbot,由于它依賴上面兩個包,所以重裝時會一并裝上: > > `bash $ sudo yum install -y certbot python2-certbot-nginx` 重新執行證書申請命令:sudo certbot --nginx 會有一系列交互式的提示,首先會讓你輸入郵箱,用于訂閱。然后輸入 a 同意他們的政策。 接著 certbot 會自動掃描出來域名,根據提示輸入想開啟 HTTPS 的域名標號: > Which names would you like to activate HTTPS for? > > * * * > > 1: django-blog-tutorial-v2-demo.zmrenwu.com > > * * * > > Select the appropriate numbers separated by commas and/or spaces, or leave input > blank to select all options shown (Enter 'c' to cancel): 1 然后 certbot 會做一個域名校驗,證明你對這個域名有控制權限。驗證通過后,Let's Encrypt 就會把證書頒發給你。 最后會提示你是否把 HTTP 重定向到 HTTPS,當然選擇是,這樣 certbot 會自動幫我們修改 Nginx 的配置,將 HTTP 重定向到 HTTPS,如果用戶使用 HTTP 協議訪問我們的博客網站,就會重定向到 HTTPS 協議訪問,確保安全性。 > Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. > > * * * > > 1: No redirect - Make no further changes to the webserver configuration. > 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for > new sites, or if you're confident your site works on HTTPS. You can undo this > change by editing your web server's configuration. > > * * * > > Select the appropriate number \[1-2\] then \[enter\] (press 'c' to cancel): 2 > Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/django-blog-tutorial-v2.conf certbot 申請的證書只有 3 個月有效期,不過沒有關系,certbot 可以無限續期,我們增加一條 crontab 定時任務用來執行 certbot 自動續期任務,這樣一次申請,終生使用。 打開 /etc/crontab,增加定時任務: ~~~bash echo "0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew" | sudo tee -a /etc/crontab > /dev/null ~~~ 這里配置每天 12 點執行自動續期命令。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看