【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四层代理功能, ...
随机推荐
- 如何更新GitHub上的代码?
更新github上的代码 一.克隆代码 1.先是把自己GitHub上的代码克隆到本地(下载到本地) 步骤1.随便创建一个新文件夹(用来存放下载下来的代码) 步骤2.在文件夹中打开cmd 输入下载指令下 ...
- 【树状数组】【P3372】 【模板】线段树 1
Description 给定一个长度为 \(n\) 的序列,有 \(m\) 次操作,要求支持区间加和区间求和. Limitation \(1 \leq n,~m \leq 10^5\) 序列元素值域始 ...
- 2019qbxtCSP-S2 模拟题1
T1 \(solution\) 求出第一个开始下降的位置,移动到连续的与它相同的数的最前面的一个数的位置,记录为\(p\) \(p\)以前的位置的数与原数相同,\(p\)位置为原数-1,后面全部为9 ...
- vb.net 判断某个文件是否已经打开了
' 判断这个excel文件是否已经打开了: 如果打开了,不能下载 Try Dim fs AsFileStream = NewFileStream(excelFileName, FileMode.O ...
- [转]Jumpserve跳板机的生产环境应用
Jumpserver是国内一款开源的轻便的跳板机系统,他们的官网:http://www.jumpserver.org/ 使用这款软件意在提高公司内部登录生产环境服务器的便捷性,权限分配细化,以及后台管 ...
- Spring Transaction 使用入门 (转)
Spring Transaction 使用入门 一.开篇陈述 1.1 写文缘由 最近在系统学习spring框架IoC.AOP.Transaction相关的知识点,准备写三篇随笔记录学习过程中的感悟.这 ...
- Redis的三个框架:Jedis,Redisson,Lettuce
Jedis api 在线网址:http://tool.oschina.net/uploads/apidocs/redis/clients/jedis/Jedis.html redisson 官网地址: ...
- 20165214 2018-2019-2 《网络对抗技术》Exp8 Web基础 Week11—12
<网络对抗技术>Exp8 Web基础 Week11-12 一.实验目标与内容 1.实践内容 (1).Web前端HTML 能正常安装.启停Apache.理解HTML,理解表单,理解GET与P ...
- Spring boot2X集成zuul与consul实现负载均衡和反向代理
zuul 是netflix开源的一个API Gateway 服务器 所有从设备或网站来的请求都会经过Zuul到达后端的Netflix应用程序. 作为一个边界性质的应用程序,Zuul提供了动态路由.监控 ...
- 代码同时支持.NET Framework和.NET Core
代码同时支持.NET Framework和.NET Core .NetCore技术研究-一套代码同时支持.NET Framework和.NET Core 在.NET Core的迁移过程中,我们将原 ...