惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Google DeepMind News
Google DeepMind News
博客园_首页
云风的 BLOG
云风的 BLOG
月光博客
月光博客
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
P
Proofpoint News Feed
D
Docker
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
博客园 - 叶小钗
Martin Fowler
Martin Fowler
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - 孤独的猫咪神

自定义贪吃蛇环境进行PPO模型训练 通过TensorBoard进行PPO参数优化 TensorBoard PPO log 解析 macos(M4)上跑强化学习 - PyTorch LunarLander-v3 Stable-Baselines3 部分机型下,Flutter的flutter_inappwebview在使用evaluateJavascript调用postMessage失败的情况 HarmonyOS中,html 与 ets 桥接沟通 Flutter中,html 与 dart 桥接沟通 Flutter 环境变量 Mole,清理Mac的小工具 Flutter自定义主题Theme最佳实践 Ubuntu 20.04 开机自动添加git的ssh 米家 + arduino + 自定义服务器 Flutter 第三方库 Jenkins CLI 通过ssh方式链接时的证书 阿里云Ubuntu 14.04 + Nginx + .net core + MySql 移动开发网络接口 经验总结 Pathoto项目:AWS+golang+beego搭建 osx开发,skport项目记录 使用Jekyll在Github上搭建博客 iOS搜索附近的位置(类似微博朋友圈位置) retrofit2中ssl的Trust anchor for certification path not found问题 Android中的Semaphore React Native 在现有项目中的探路 博客园 Linux客户端 2.0 正式发布! 博客园 Windows客户端 2.0 正式发布! 博客园 Mac客户端 2.0 正式发布!
阿里云Ubuntu 14.04 + Nginx + let's encrypt 搭建https访问
孤独的猫咪神 · 2016-11-29 · via 博客园 - 孤独的猫咪神

参考页面:

https://certbot.eff.org/#ubuntutrusty-nginx

http://bbs.qcloud.com/thread-12059-1-1.html

http://www.cnblogs.com/yanghuahui/archive/2012/06/25/2561568.html

http://www.jb51.net/os/Ubuntu/323696.html

1. 下载let's encrypt

$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install certbot 

  无法找到add-apt-repository时,需要

apt-get install python-software-properties
apt-get install software-properties-common

2. 生成密钥

certbot certonly --standalone -d example.com -d www.example.com

执行成功会显示如下内容:

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/【这里是你的域名】/fullchain.pem. Your cert will
   expire on 【这里是到期时间】. To obtain a new or tweaked version of this
   certificate in the future, simply run certbot-auto again. To
   non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - If you like Certbot, please consider supporting our work by:

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

  红色内容在下一步会被使用。

3. 配置nginx

        listen 443 ssl;
        ssl_certificate /etc/letsencrypt/live/【这里是你的域名】/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/【这里是你的域名】/privkey.pem;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;
        listen [::]:443 ssl ipv6only=on;

  请注意这里的两个红色路径所对应的文件不相同。

4. 重启nginx

  这时通过https访问网站,访问成功。

  通过http访问网站,失败。错误:ERR_CONNECTION_REFUSED

5. 重定向http访问到https

server {
        listen 80;
        server_name 【这里是你的域名】;
        rewrite ^(.*) https://$server_name$1 permanent;
}

  再次访问http,成功。  

至此,配置完成。如下图

* let's encrypt 只有90天的期限,续期使用如下代码:

certbot renew --dry-run 
certbot renew

  此操作前,请先关闭nginx

 重启nginx,可能会遇到 [error] open() "/run/nginx.pid" failed (2: No such file or directory) 这样的问题,解决方法如下(参考自:http://blog.csdn.net/llnara/article/details/8691049):

nginx -c /etc/nginx/nginx.conf

欢迎访问我的网站:https://maomishen.com/