『译』在你的 WordPress 项目中使用 Let's Encrypt SSL

8/11/2016
0
HTTPS、译文

原文链接:Using Let’s Encrypt SSL With Your WordPress Project

什么是 Let’s Encrypt?

多年来购买、更新、安装以及管理 SSL 证书,其昂贵的价格和复杂性让我不知所措。现在, Let’s Encrypt 使得它相当简单而且免费。

Let’s Encrypt 是由加州公益组织称为互联网安全研究小组带来的新兴的、自由的、自动化的、开放的证书颁发机构,它也有非营利性的成分。

它的目标是让 HTTPS 成为浏览器的默认协议,从而更好地确网络保隐私和安全。 Mozilla 和 Electronic Frontier Foundation(电子前沿基金会) 是它的两个主要赞助商:

Whats Lets Encrypt Platinum sponsors

Let’s Encrypt 在十二月进入公测, 所以现在我能很容易地指导你去探索它的服务。

在这篇教程中, 我将带你在我的几个网站中安装 Let’s Encrypt , 包括我的 WordPress 咨询网站, http://lookahead.io 很快就会成为 https://lookahead.io

在我们开始之前,请记住,我会参与下面的讨论。如果你有问题或者建议,请在下面发表评论或者 contact me on Twitter @reifman.

Let’s Encrypt  功能总结

Let’s Encrypt 运行在使用 Python 的 Apache 服务器上,以此来实现自动注册和更新证书,简化了网站激活 HTTPS 的过程,包括 WordPress 。

这里有 Let’s Encrypt 的主要优势:

  • 免费:  任何一个域名都可以无成本地注册一个受信任的证书。

  • 自动:  一个 Apache Web 服务器可以轻松获得证书, 安全配置, 并且自动管理更新。

  • 安全: 无论是作为一个证书颁发机构,还是帮助维护服务器上的网站安全,Let’s Encrypt 将推动 TLS 安全最佳实践。

  • 透明:  证书的所有交易记录公开,并且可供查阅。

  • 开放:  自动发布和更新协议将作为一个开放的标准。

  • 协作: Let’s Encrypt 是社区的努力,造福每一个人。

使用  Let’s Encrypt 安装 SSL

让我们开始,通过更新我的服务器,Apache Ubuntu。

sudo apt-get update

如果你没有在你的服务器上安装 Git,用 Git 来安装 Let’s Encrypt 是最好的:

sudo apt-get install git

一旦安装完,把 Let’s Encrypt software 克隆到 Apache 第三方应用程序的 opt 子目录下:

sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt

首先,我将在 Fever 新闻阅读器上尝试安装 Let’s Encrypt,而不是 WordPress。我把它托管在 http://fever.lookahead.io

cd /opt/letsencrypt
./letsencrypt-auto --apache -d fever.lookahead.io

设置向导

开始时, 会要求填写电子邮件:

Lets Encrypt Installation Email Request

然后显示服务条款:

Lets Encrypt Installation Terms of Service

Let’s Encrypt 给你提供了将 HTTPS 作为第二选项,或者直接使用 HTTPS 将接管所有流量的连个选项:

Lets Encrypt Select HTTPS mode

你在几分钟内搞定:

Lets Encrypt Congratulations

你也会看到一些证书到期和更新的信息:

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/lookahead.io/fullchain.pem. Your cert will
   expire on 2016-05-03\. To obtain a new version of the certificate in
   the future, simply run Let's Encrypt again.
 - Your account credentials have been saved in your Let's Encrypt
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Let's
   Encrypt so making regular backups of this folder is ideal.
 - If you like Let's Encrypt, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

在 WordPress 上安装

在我的 WordPress 咨询网站安装 Let’s Encrypt SSL,同样非常简单。只有那么一丢丢地不同,我想让 Let’s Encrypt 能更好地支持 www 子域名:

cd /opt/letsencrypt
./letsencrypt-auto --apache -d lookahead.io -d www.lookahead.io

你现在可以去访问了,是 HTTP 或者 HTTPS, 将会在这里终结,https://lookahead.io

Lets Encrypt Lookahead Consulting

SSL 报告

你可以去类似 Qualys SSL Labs 的网站来获得你的网站的 SSL 报告。

https://www.ssllabs.com/ssltest/analyze.html?d=fever.lookahead.io

Lets Encrypt SSL Qualys Labs

这儿是认证页面:

Lets Encrypt SSL Qualys Labs Authentication

证书自动更新

自动更新也相当简单。首先,我们获取更新脚本,并赋予它执行权限:

sudo curl -L -o /usr/local/sbin/le-renew http://do.co/le-renew
sudo chmod +x /usr/local/sbin/le-renew

Lets Encrypt Set up auto renewals

让后为每个域名运行这个脚本:

sudo le-renew lookahead.io
Checking expiration date for fever.lookahead.io...
The certificate is up to date, no need for renewal (89 days left).

你可以设置一个 cron job 来有规律地运行:

crontab -e

添加这行:

30 2 * * 1 /usr/local/sbin/le-renew lookahead.io >> /var/log/le-renew.log

故障排除

我想分享一下我遇到的问题,当我为 Community Starter open-source project (都是根域名和 www)安装 SSL 时,Let’s Encrypted 给出这个错误:

We were unable to find a vhost with a ServerName or Address of
    │ www.communitystarter.org.
    │ Which virtual host would you like to choose?

我在配置文件里设置了一个通配符别名:

<VirtualHost *:80>
        ServerName communitystarter.org
        ServerAlias *.communitystarter.org
        DocumentRoot /var/www/communitystarter/

这个变化修复了它,为 www 增加一个别名:

<VirtualHost *:80>
        ServerName communitystarter.org
        ServerAlias www.communitystarter.org
        ServerAlias *.communitystarter.org
        DocumentRoot /var/www/communitystarter/

然后,主页嵌入 Vimeo 视频失败:

Lets Encrypt Vimeo Not Working with HTTPS

我不得不使 iframe 里的 Vimeo 播放器使用 HTTPS:

<!-- ***************** - START Video - ***************** -->
<div class="video-wrap video_left">
<div class="video-main">
<div class="video-frame">
<iframe src="https://player.vimeo.com/video/37639283" title="introduction to newscloud's community starter" scrolling="no" width="572" height="312" frameborder="0" marginheight="0"></iframe>
</div><!-- end video-frame -->
</div><!-- end video-main -->
<div class="video-sub">
<h2>NewsCloud's Community Starter</h2>
 <p>Community Starter is a simple, affordable platform to launch social media communities and extend existing websites. It provides a suite of Facebook-connected interactive features that can help you host a vibrant online community for your neighborhood, topic, community group, nonprofit, membership association or city.</p>
<a href="/how-community-foundations-can-build-engaged-local-communities-with-newscloud.html" class="ka_button small_button small_tealgrey"><span>Start your community →</span></a><br class="clear" />
</div><!-- end video-sub -->
</div><!-- end video-wrap -->
<!-- ***************** - END Video - ***************** -->

问题解决:

Lets Encrypt Vimeo Working with HTTPS

在结束前

我对社区的目标印象非常深刻,Let’s Encrypt 提供了质量和便利性。无处不在的网络出版商将从简单免费的 SSL 中获益,感谢 EFF、Mozilla 以及 Let’s Encrypt!

Lets Encrypt Donate

您可以捐赠 Let’s Encrypt 或者 EFF 来支持这项工作:

你可以  了解更多关于他们软件的技术细节。Let’s Encrypt 也有一个良好的  社区论坛:

Lets Encrypt Community Forum

下一步?

Let’s Encrypt 正在积极努力地完成其首次公开发行:

我们还有很多工作要做在我们完全丢弃测试标签之前,特别是在客户端的体验上。自动化是我们策略的基础。我们需要确保广泛的客户端平台平稳可靠运行。

要跟随最新的代码,只要偶尔跟新你的 git 树:

cd /opt/letsencrypt
sudo git pull

我私人的 WordPress 目前运行的是 Varnish 3.x。这与 Let’s Encrypt 并不能立即使用,我可能会花一些时间跟踪解决。

与此同时,如果你正在寻找其他的实用工具来帮助你建立不断增长的 WordPress 代码集或者变得更精通 WordPress,别忘了看  we have available in Envato Market.

如果你有问题,请请发表在下面。或者你可以  contact me on Twitter @reifman。请访问  my Envato Tuts+ instructor page  来查看我写的其他教程。例如  Cloning WordPress in Linux (in 90 seconds).

译者说

由于水平受限,文中有不恰当之处,还请读者谅解并在评论中指出,以便改正!


商业转载请联系站长获得授权,非商业转载请注明本文出处及文章链接,您可以自由地在任何媒体以任何形式复制和分发作品,也可以修改和创作,但是分发衍生作品时必须采用相同的许可协议。
本文采用 CC BY-NC-SA 4.0 - 非商业性使用 - 相同方式共享 4.0 国际进行许可。