Https实践
https实践
常用端口
ssh 22
telnet 23
ftp 21
rsync 873
http 80
mysql 3306
redis 6379
https 443
dns 53
php 9000
tomcat 8080
https介绍
什么是https?
http是超文本传输协议。(不安全)
https是加密的传输协议。(数据加密传输更安全,不加密网站容易被篡改)
当我们使用http网站时,会遭到劫持和篡改,如果采用https协议,那么数据在传输过程中是加密的,所以黑客无法窃取或者篡改数据报文信息,同时也避免网站传输时信息泄露。
如何使用https,配置
证书类型
- 单域名
- 多域名
- 通配域名
注意事项
- https证书不支持续费,到期之后需要重新申请。
- https不支持三级域名,如:test.gong.xxx.com
http三种颜色
- 红色:网页中有不安全的链接http
- 黄色:代码中包含http不安全的连接
- 绿色:安全的链接
证书类型介绍
| 对比 | 域名型 DV | 企业型 OV | 增强型 EV |
|---|---|---|---|
| 绿色地址栏 | 小锁标记+https |
小锁标记+https |
小锁标记+企业名称+https |
| 一般用途 | 个人站点和应用; 简单的https加密需求 | 电子商务站点和应用; 中小型企业站点 | 大型金融平台; 大型企业和政府机构站点 |
| 审核内容 | 域名所有权验证 | 全面的企业身份验证; 域名所有权验证 | 最高等级的企业身份验证; 域名所有权验证 |
| 颁发时长 | 10分钟-24小时 | 3-5个工作日 | 5-7个工作日 |
| 单次申请年限 | 1年 | 1-2年 | 1-2年 |
| 赔付保障金 | —— | 125-175万美金 | 150-175万美金 |
单台实现https
https的实现需要有ngx_http_ssl_module的支持,安装方法
This module is not built by default, it should be enabled with the --with-http_ssl_module configuration
# 使用nginx -V 可查看是否安装了这个模块。
语法格式.官方
server {
# 开启443端口
listen 443 ssl;
# 证书的位置
ssl_certificate /usr/local/nginx/conf/cert.pem;
ssl_certificate_key /usr/local/nginx/conf/cert.key;
}
配置
# 1、创建放置证书的目录
[root@web01 ~]# mkdir /etc/nginx/ssl
# 使用openssl命令充当CA权威机构创建证书(生产不使用此方式生成证书,不被互联网认可的黑户证书)
[root@web01 /etc/nginx/ssl]# openssl genrsa -idea -out server.key 2048
Generating RSA private key, 2048 bit long modulus
........................................................................+++
......................+++
e is 65537 (0x10001)
# 输入一个密码最小4位,只是配置过程中用
Enter pass phrase for server.key:
Verifying - Enter pass phrase for server.key:
[root@web01 /etc/nginx/ssl]# openssl req -days 36500 -x509 -sha256 -nodes -newkey rsa:2048 -keyout server.key -out server.crt
Generating a 2048 bit RSA private key
.....................+++
...........................+++
writing new private key to 'server.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:chongqing
Locality Name (eg, city) [Default City]:dazu
Organization Name (eg, company) [Default Company Ltd]:better
Organizational Unit Name (eg, section) []:yunxingweihubu
Common Name (eg, your name or your server's hostname) []:gong.com
Email Address []:123@qq.com
# 这几步根据提示的做就好,在域名那里,老师说的是,要和绑定的域名的顶级域相同,实际在配置的过程中没有使用这个域名也能够成功访问
# req --> 用于创建新的证书
# new --> 表示创建的是新证书
# x509 --> 表示定义证书的格式为标准格式
# key --> 表示调用的私钥文件信息
# out --> 表示输出证书文件信息
# days --> 表示证书的有效期
[root@web01 /etc/nginx/conf.d]# vi https.conf
server {
# 监听443端口
listen 443 ssl;
server_name www.shelldon.com;
# 防止证书和公钥的位置
ssl_certificate ssl/server.crt;
ssl_certificate_key ssl/server.key;
location / {
root /website/https;
index index.html;
}
}
server {
listen 80;
server_name www.shelldon.com;
# 用户访问http的时候强制跳转443
return 302 https://$server_name$request_uri;
}
[root@web01 ~]# mkdir /website/https
[root@web01 ~]# echo https website > /website/https/index.html

多台实现https
负载均衡上的配置,在实际过程中,只需要在负载均衡上配置https就可以了,内网通信使用http。
[root@lb01 ~]# vi /etc/nginx/conf.d/upstream.conf
upstream blog {
server 172.16.1.7;
server 172.16.1.8 down;
server 172.16.1.9 down;
}
# 80做的都是http强转https
server {
listen 80;
server_name wp.gong.com;
return 302 https://$server_name$request_uri;
}
server {
listen 80;
server_name zh.gong.com;
return 302 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name wp.gong.com;
ssl_certificate ssl/server.crt;
ssl_certificate_key ssl/server.key;
location / {
proxy_pass http://blog;
include proxy_params;
}
}
server {
listen 443 ssl;
server_name zh.gong.com;
ssl_certificate ssl/server.crt;
ssl_certificate_key ssl/server.key;
location / {
proxy_pass http://blog;
include proxy_params;
}
}
web中的配置
[root@web01 ~]# vi /etc/nginx/conf.d/wp.conf
server {
listen 80;
server_name wp.gong.com;
root /website/wp;
index index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# 在这里要告诉php,负载均衡那里已经使用80跳转443了,使用https访问
fastcgi_param HTTPS on;
include fastcgi_params;
}
}
[root@web01 /etc/nginx/conf.d]# vi zh.conf
server {
listen 80;
server_name zh.gong.com;
root /website/zh;
index index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
include fastcgi_params;
}
}
ssl优化参数
https使用在负载均衡中。
server {
listen 443 ssl;
server_name blog.driverzeng.com;
root /var/www/wordpress;
index index.php;
# 指定证书的路径
ssl_certificate ssl/215089466160853.pem;
ssl_certificate_key ssl/215089466160853.key;
include ssl_params;
}
#在建立完ssl握手后如果断开连接,在session_timeout时间内再次连接,是不需要再次获取公钥建立握手的,可以使用之前的连接
ssl_session_cache shared:SSL:10m;
#ssl连接断开后的超时时间
ssl_session_timeout 1440m;
#配置加密套接协议
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#使用TLS版本协议
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#nginx决定使用哪些协议与浏览器通信
ssl_prefer_server_ciphers on;
[root@lb01 /etc/nginx]# vi ssl_params
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1440m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
Https实践的更多相关文章
- 【百度】大型网站的HTTPS实践(二)——HTTPS加密算法介绍
大型网站的HTTPS实践(二)——HTTPS加密算法介绍 原创 网络通信/物联网 作者:AIOps智能运维 时间:2018-11-09 15:09:43 358 0 前言 在上一篇文章中,我们简要 ...
- 【百度】大型网站的HTTPS实践(一)——HTTPS协议和原理
大型网站的HTTPS实践(一)——HTTPS协议和原理 原创 网络通信/物联网 作者:AIOps智能运维 时间:2018-11-09 15:07:39 349 0 前言 百度于2015年上线了全站 ...
- 17、Nginx HTTPS 实践
1.HTTPS安全证书基本概述 为什么需要使用HTTPS, 因为HTTP不安全.当我们使用http网站时,会遭到劫持和篡改,如果采用https协议,那么数据在传输过程中是加密的,所以黑客无法窃取或者篡 ...
- Qzone 高性能 HTTPS 实践
WeTest导读 自从去年QQ空间移动端页面开始切换到HTTPS之后,页面性能遇到了比较大的挑战,HTTPS对页面访问速度带来了比较大的影响,所以我们通过实践总结了一些能够提升HTTPS页面访问速度的 ...
- 大型网站的 HTTPS 实践(三)——基于协议和配置的优化
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt389 1 前言 上文讲到 HTTPS 对用户访问速度的影响. 本文就为大家介 ...
- 大型网站的 HTTPS 实践(四)——协议层以外的实践
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt390 1 前言 网上介绍 https 的文章并不多,更鲜有分享在大型互联网站 ...
- nginx+tomcat https实践
1. 安装ssl'证书 使用Let's Encrypt 的免费证书: 下载源代码: git clone https://github.com/letsencrypt/letsencrypt 我时阿里云 ...
- 大型网站的 HTTPS 实践(1):HTTPS 协议和原理
转自:http://op.baidu.com/2015/04/https-s01a01/ 1 前言 百度已经于近日上线了全站 HTTPS 的安全搜索,默认会将 HTTP 请求跳转成 HTTPS.本文重 ...
- 大型网站的 HTTPS 实践(一)—— HTTPS 协议和原理
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt387 1 前言 百度已经于近日上线了全站 HTTPS 的安全搜索,默认会将 ...
随机推荐
- 这可能是最容易理解的 Go Mutex 源码剖析
Hi,大家好,我是 haohongfan. 上一篇文章<一文完全掌握 Go math/rand>,我们知道 math/rand 的 global rand 有一个全局锁,我的文章里面有一句 ...
- 配置Jupyter环境:安装+补全+美化+常用库
1 Jupyter简介 Jupyter Notebook是一个交互式笔记本,支持运行40多种编程语言,本质是一个Web应用程序,便于创建和共享文学化程序文档,支持实时代码,数学方程,可视化和Markd ...
- Redhat 安装gitlab
以下为8月23日左右记录的,没有发布.今日整理大概记录下. 安装依赖包 yum install -y curl policycoreutils-python openssh-server openss ...
- 安装电脑思考到了Java设计模式:建造者模式
目录 定义 意图 主要解决问题 何时使用 优缺点 结构 组装电脑的例子 定义 建造者模式是对象的创建型模式,可以将一个产品的内部表象与产品的生成过程分割开来,从而可以使一个建造过程生成具有不同的内部表 ...
- HACK TEH BOX - Under Construction(JWT密钥混淆 + SQL注入)
HACK TEH BOX - Under Construction(JWT密钥混淆 + SQL注入) 目录 1. JWT密钥混淆 2. 环境 3. Challenge 4. Walkthrough 1 ...
- Day06_27_多态
多态 最关键一句话: 父类引用 指向(=) 子类对象 Animal a = new Cat(); 什么是多态? 官方说: 接口的多种不同的实现方式即为多态. 多态性是允许你将父对象设置成为一个或更多的 ...
- WinForm只运行运行一个实例(单开)
using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Windows.F ...
- spring boot @Schedule 如何定时请求任务
spring boot 定时任务,添加两个注解即可: 1,启动类添加:@EnableScheduling 2,方法上添加注解:@Scheduled(cron = "0/5 * * * * ? ...
- 906. Super Palindromes
Let's say a positive integer is a superpalindrome if it is a palindrome, and it is also the square o ...
- 【多线程】Java线程池七个参数详解
/** * Creates a new {@code ThreadPoolExecutor} with the given initial * parameters. * * @param coreP ...
小锁标记+https
小锁标记+https
小锁标记+企业名称+https