阿里云Ubuntu 14.04 + Nginx + let's encrypt 搭建https访问
参考页面:
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
nginx -s reload
这时通过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 -s stop
重启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/
阿里云Ubuntu 14.04 + Nginx + let's encrypt 搭建https访问的更多相关文章
- 阿里云Ubuntu 14.04 + Nginx + .net core + MySql
前段时间帮朋友写了一个网站,现在做一个记录. .Net Core 安装: curl https://packages.microsoft.com/keys/microsoft.asc | gpg -- ...
- 在阿里云Ubuntu 14.04 Linux服务器上安装docker
参考 How To Install and Use Docker: Getting Started 这篇最靠谱的文档在阿里云 Ubuntu 14.04 服务器上成功安装 docker . ---- ...
- 阿里云 ubuntu 14.04 模板上安装 docker
ubuntu 14.04 的内核是 3.13 ,所以内核不用升级. 安装过程例如以下: # apt-get update # apt-get install apt-transport-https # ...
- 阿里云 Ubuntu 14.04 安装mysql 5.6
1. 升级apt-get apt-get update 如果出现 : 说明没有你不是root用户,则需要用sudo命令 sudo apt-get update 下面出现权限问题都可以参照这个方法. 2 ...
- 在阿里云Ubuntu 14.04.5 LTS下安装nethogs0.8.5
由于默认安装的nethogs不能使用,提示:Creating socket failed while establishing local IP - are you root? 搜索资料后检查当前版本 ...
- Nginx模块之————RTMP模块在Ubuntu 14.04年的设置与搭建
Nginx的设置,RTMP在Ubuntu 14.04 https://www.vultr.com/docs/setup-nginx-rtmp-on-ubuntu-14-04
- 阿里云ubuntu 16.04 搭建pptpd 第二版
前言:1.我常用的服务器在国内,但我又有某方面的需求,所以想要搭建一个pptpd的服务器 2.但我又不常用,所以感觉阿里云包年包月的不划算,所以准备采用阿里云按量付费的实例来搭建pptpd,并形 ...
- Ubuntu 14.04.5 imx6 开发环境搭建
1,下载VMware Workstation虚拟机 地址:http://1.xp510.com:801/xp2011/VMware10.7z 2,下载Ubuntu 14.04.5 LTS 32位Ubu ...
- Laravel项目部署上线(阿里云 Ubuntu 16.04)
第一次尝试把本地的项目上线, 购买了某云的轻量应用服务器, 镜像为Ubuntu 16.04 直接运行 apt-get install nginx 出错 根据提示运行 apt-get upda ...
随机推荐
- MySQL数据库备份命令
原文参考:MySQL数据库备份的命令 - 司南 mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql备 ...
- jquery简单入门(一)
相关: 本文参考<锋利的jQuery第二版> 写在前面: jQuery作为javascript框架,是做网页交互工作者,一个值得学习的优秀的前端框架... 百度指数分析:(http://i ...
- python关键字,运算符
关键字: and且 or 或 not否 del import导入 from import的来源 whilewhile循环 for for循环 if elif else条件结构 break contin ...
- Js apply call方法详解【转】
我在一开始看到javascript的函数apply和call时,非常的模糊,看也看不懂,最近在网上看到一些文章对apply方法和call的一些示例,总算是看的有点眉目了,在这里我做如下笔记,希望和大家 ...
- OpenCV 之 边缘检测
上一篇 <OpenCV 之 图像平滑> 中,提到的图像平滑,从信号处理的角度来看,实际上是一种“低通滤波器”. 本篇中,数字图像的边缘,因为通常都是像素值变化剧烈的区域 (“高频”),故可 ...
- Vijos1392拼拼图的小衫[背包DP|二维信息DP]
背景 小杉的幻想来到了经典日剧<死亡拼图>的场景里……被歹徒威胁,他正在寻找拼图(-.-干嘛幻想这么郁闷的场景……). 突然广播又响了起来,歹徒竟然又有了新的指示. 小杉身为新一代的汤浅, ...
- MySQL 5.7.x 配置教程
软件环境 操作系统:windows 10 x64 企业版 MySQL:mysql-5.7.11-winx64 MySQL官网下载:http://downloads.mysql.com/archives ...
- ASP.NET MVC
ASP.NET MVC 就是根据 Model 2 模式设计的.对于 HTTP 请求的拦截以实现对目标 Controller 和 Action 的解析是通过一个自定义 Http Module 来实现的, ...
- OAuth2学习及DotNetOpenAuth部分源码研究
OAuth2学习及DotNetOpenAuth部分源码研究 在上篇文章中我研究了OpenId及DotNetOpenAuth的相关应用,这一篇继续研究OAuth2. 一.什么是OAuth2 OAuth是 ...
- GNU make规则的命令④书写命令
命令回显 通常, make 在执行命令行之前会把要执行的命令行输出到标准输出设备.我们称之为"回显",就好像我们在 shell 环境下输入命令执行时一样. 如果规则的命令行以字符& ...