mer*_*att 4 ssl https heroku ssl-certificate meteor
我想将我的Meteor应用程序部署到Heroku,并且只能通过HTTPS访问它.理想情况下,我想尽可能便宜地做到这一点.
运行这些命令以获取certbot-auto.certbot-auto应该适用于大多数系统
wget https://dl.eff.org/certbot-auto
chmod 755 certbot-auto
Run Code Online (Sandbox Code Playgroud)
此命令将启动获取证书的过程.该-d标志允许您传入您想要保护的域.或者,如果没有该-d标志,它将弹出一个提示,您可以在其中输入域.
./certbot-auto certonly --manual -d app.yoursite.com
Run Code Online (Sandbox Code Playgroud)
然后它会问你以下.不要输入.
Make sure your web server displays the following content at
http://app.yoursite.com/.well-known/acme-challenge/SOME-LENGTHY-KEY before continuing:
SOME-LONGER-KEY
Run Code Online (Sandbox Code Playgroud)
我建议使用此方法,因为在续订时,您只需要更新环境变量.您可以使用public/如下,但每次都需要重建整个应用程序
跑 meteor add meteorhacks:picker
在服务器端文件中,添加以下内容
import { Picker } from 'meteor/meteorhacks:picker';
Picker.route('/.well-known/acme-challenge/:routeKey', (params, request, response) => {
response.writeHead('200', {'Content-Type': 'text/plain'});
response.write(process.env.SSL_PAGE_KEY)
response.end();
});
Run Code Online (Sandbox Code Playgroud)
然后将环境变量SSL_PAGE_KEY设置SOME-LONGER-KEY为
heroku config:set SSL_PAGE_KEY=SOME-LONGER-KEY
Run Code Online (Sandbox Code Playgroud)
在public文件夹中创建目录路径.如果您没有,请创建一个.
mkdir -p public/.well-known/acme-challenge/
Run Code Online (Sandbox Code Playgroud)
然后创建文件SOME-LENGTHY-KEY并放在SOME-LONGER-KEY其中
echo SOME-LONGER-KEY > public/.well-known/acme-challenge/SOME-LENGTHY-KEY
Run Code Online (Sandbox Code Playgroud)
提交并推送更改到您的Heroku应用程序.
git push heroku master
Run Code Online (Sandbox Code Playgroud)
现在点击Enter继续验证过程.你应该收到这样的消息
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/app.yoursite.com/fullchain.pem. Your cert will
expire on 2016-04-11. To obtain a new version of the certificate in
the future, simply run Let's Encrypt again.
Run Code Online (Sandbox Code Playgroud)
要将证书上传到Heroku,请先启用SSL Beta
heroku labs:enable http-sni -a your-app
heroku plugins:install heroku-certs
Run Code Online (Sandbox Code Playgroud)
然后添加你的fullchain.pem和privkey.pemHeroku.
sudo heroku _certs:add /etc/letsencrypt/live/app.yoursite.com/fullchain.pem /etc/letsencrypt/live/app.yoursite.com/privkey.pem
Run Code Online (Sandbox Code Playgroud)
您可以验证证书是否已上载
heroku _certs:info
Run Code Online (Sandbox Code Playgroud)
更新您的DNS以指向 app.yoursite.com.herokudns.com
要检查是否已设置SSL,请运行以下命令.-v给你详细的输出.-I仅显示文档信息.-H将标头传递给URL.我们传递的标头确保没有使用缓存,并确保您获得新证书而不是旧证书.
curl -vI https://app.yoursite.com -H "Cache-Control: no-cache"
Run Code Online (Sandbox Code Playgroud)
检查输出是否包含以下内容
* Server certificate:
* subject: C=US; ST=CA; L=SF; O=SFDC; OU=Heroku; CN=app.yoursite.com
Run Code Online (Sandbox Code Playgroud)
如果该subject行不包含CN=app.yoursite.com,请等待5到10分钟再试一次.如果确实如此,那你就差不多了.
要完成此过程,您需要将ROOT_URL环境变量更改为新https版本.
heroku config:set ROOT_URL=https://app.yoursite.com
Run Code Online (Sandbox Code Playgroud)
然后,您需要确保您的用户始终在force-ssl程序包中使用SSL
meteor add force-ssl
Run Code Online (Sandbox Code Playgroud)
最后,如果您在应用中设置了任何OAuth登录(Facebook,Google等),则需要向他们提供新https版本的网址.
再跑certbot-auto一次
./certbot-auto certonly --manual -d app.yoursite.com
Run Code Online (Sandbox Code Playgroud)
它可能会提示您输入具有相同内容的相同端点.如果是,只需按Enter键.如果没有,您将需要重复上述步骤.
然后它将创建新的证书文件,您将上传到Heroku
heroku certs:update /etc/letsencrypt/live/app.yoursite.com/fullchain.pem /etc/letsencrypt/live/app.yoursite.com/privkey.pem
Run Code Online (Sandbox Code Playgroud)
然后确认,运行上面的验证SSL工作命令
来源
| 归档时间: |
|
| 查看次数: |
732 次 |
| 最近记录: |