【Nginx】将http升级到https并且同时支持http和https两种请求
一、如何将http升级到https
需要满足下面三个:
)检查 Nginx 是否支持 SSL
/usr/local/nginx/sbin/nginx -V
configure arguments中是否有--with-http_ssl_module
如:
nginx version: nginx/1.13.
built by gcc 4.8. (Red Hat 4.8.-) (GCC)
built with OpenSSL 1.0.2k-fips Jan
TLS SNI support enabled
configure arguments: --with-http_ssl_module
) 若不支持,为nginx添加SSL 模块
进入nginx安装目录执行:
./configure --with-http_ssl_module
然后,注意不要make install
make
)备份原 Nginx 执行脚本
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
)将新版本 Nginx 编译脚本放到可执行文件目录下
cd objs/ cp nginx /usr/local/nginx/sbin/
)进行平滑升级
make upgrade
2.2.编辑Nginx配置文件
server {
listen ssl;
server_name 你的域名;
ssl_certificate 你的证书.crt;
ssl_certificate_key 你的证书.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
二、同时支持http和https两种请求
nginx配置新增server的配置
# http -> https
server {
listen ;
server_name 你的域名;
rewrite ^(.*)$ https://$host$1 permanent;
}
【Nginx】将http升级到https并且同时支持http和https两种请求的更多相关文章
- nginx将http升级到https并且同时支持http和https两种请求、http自动转向https
1.http升级到https 1.1.检查 Nginx 是否支持 SSL /usr/local/nginx/sbin/nginx -V configure arguments中是否有--with-ht ...
- Nginx 反向代理(http转htpps,并支持80端口继续提交post请求)
项目是一个web server + 多个client的形式,client由用户安装在自己的电脑上 由http升级为https后,我们通过在Nginx做了80端口重定向443的配置,使用户通过访问htt ...
- nginx开启ssl并把http重定向到https的两种方式
1 简介 Nginx是一个非常强大和流行的高性能Web服务器.本文讲解Nginx如何整合https并将http重定向到https. https相关文章如下: (1)Springboot整合https原 ...
- nginx 和 tp兼容pathinfo和rewrite两种url访问方式
环境:centos7,yum安装的nginx1.10.php-fpm,tp3.2 本方法只需要配置nginx.conf的一个文件就可以支持pathinfo和rewrite两种url访问方式 vim / ...
- nginx、TP框架实现兼容pathinfo和rewrite两种url访问方式
环境:centos7,yum安装的nginx1.10.php-fpm,tp3.2 本方法只需要配置nginx.conf的一个文件就可以支持pathinfo和rewrite两种url访问方式 vim / ...
- 配置nginx支持ssl服务器—HTTPS
下文摘自: http://docs.bigbluebutton.org/install/install.html Configuring HTTPS on BigBlueButtonAncho ...
- 源码安装nginx以及平滑升级
源码安装nginx以及平滑升级 ...
- Nginx配置同一个域名同时支持http与https两种方式访问
Nginx配置同一个域名http与https两种方式都可访问,证书是阿里云上免费申请的 server{listen 80;listen 443 ssl;ssl on;server_name 域名;in ...
- nginx的平滑升级
一:解释nginx的平滑升级 随着nginx越来越流行,并且nginx的优势也越来越明显,nginx的版本迭代也来时加速模式,1.9.0版本的nginx更新了许多新功能,例如stream四层代理功能, ...
随机推荐
- Vue中的v-bind指令
普通: property="value" 此时 value为字符串 v-bind指令 v-bind:property="value" 此时 value会被解析成 ...
- quick如何打开工程或者示例
quick如何打开工程或者示例 1. 那里打开工程 cc.ui.UIPushButton.new(images, {scale9 = true}) :setButtonSize(buttonWidth ...
- python 使用nmap 模块
官网 https://pypi.org/project/python-nmap/ >>> import nmap>>> nm = nmap.PortScannerS ...
- Shiro框架详解 tagline
之间工作中曾经用到过shiro这个权限控制的框架,之前一直都是停留在用的方面,没有过多的 去理解这方面的知识,现在有时间,专门研究了一下这个Shiro权限的框架使用. Shiro是什么? ...
- windows下的文件管理工具--total commander
https://www.ghisler.com/ http://www.guyiren.com/archives/1647
- 不一样的LCA——luoguP1852跳跳棋
洛谷端题目链接 loj端题目链接 题目大意: 在一条数轴上进行跳跳棋游戏.棋子只能摆在整点上.每个点不能摆超过一个棋子.用跳跳棋完成:棋盘上有3颗棋子,分别在a,b,c这三个位置.我们要通过最少的跳动 ...
- Django ORM 数据库增删改查
Django ORM 数据库增删改查 增 # 创建.增加数据(推荐) models.UserInfo.objects.create(username=') # 创建.增加数据 dic = {'} mo ...
- Mysql系列(四) —— MySQL的Charset和Collation
本文转载自:再见乱码:5分钟读懂MySQL字符集设置 一.内容概述 在MySQL的使用过程中,了解字符集.字符序的概念,以及不同设置对数据存储.比较的影响非常重要.不少同学在日常工作中遇到的" ...
- 6、VUE指令
1.指令的格式 1.1. 指令的概念 指令是指带有v-前缀的特殊属性,指令的职责是当其表达式的值改变时,相应的将某些行为应用到DOM上. 1.2. 指令必须是html的属性 指令只能以带前缀的html ...
- SecureCRT上传本地文件到linux
1.使用crt登录到需要操作的linux系统 2.按Alt+P打开sftp传输界面 3.输入pur指令加文件路径,例如:put E://srs-3.0.zip按enter就可以 4.再返回crt界面, ...