【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四层代理功能, ...
随机推荐
- CPU 的由来
由 c# 的CEF 框架提供的 js 扩展,WebBrowser. JavascriptObjectRepository. 问:为什么要提供这一种方式. 提供了一种 能让js 与后端代码通讯的 方式. ...
- 洛谷P3063 [USACO12DEC]牛奶的路由Milk Routing
链接 其实在博客园里写题解都挺应付的都是在洛谷写了之后 挑一部分粘过来 在洛谷写的也都是废话,是为了凑篇幅 主要就是代码 大体思路就一提 这题贪心不行废话 跑m遍SPFA更新最小值 注意数组记得清空 ...
- C语言实现聊天室软件
/* common.h */ /*服务器端口信息*/ #define PORTLINK ".charport" /*缓存限制*/ #define MAXNAMELEN 256 #d ...
- PyCharmIDE: 给脚本传递参数
- nginx配置神器
原文 https://mp.weixin.qq.com/s/zFEk7XzHj3xPReDXEnQxcQ https://nginxconfig.io/ Nginx作为一个轻量级的HTTP服务器,相比 ...
- git filter-branch之后撤销到原来状态
起因 因为要拆分仓库,所以按照原来的操作拆分,拆分完成后发现有问题,所以准备还原重新拆分. 注意 git filter-branch之后,不可以做其他额外操作 运行git filter-branch之 ...
- Beta/Gamma事后分析
目录 设想和目标 计划 资源 变更管理 设计/实现 测试/发布 团队的角色,管理,合作 总结 对照敏捷开发的原则, 你觉得你们小组做得最好的是哪几个原则? 请列出具体的事例. 照片 设想和目标 我们的 ...
- cad.net 块裁剪边界反向修剪
Querying for XCLIP information inside AutoCAD using .NET 这里下面观众讨论了 How do I determine if an x-clip ...
- 图论 --- 骑士周游问题,DFS
A Knight's Journey Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 28630 Accepted: ...
- 大一0基础小白用最基础C写哥德巴赫猜想
#include <stdio.h>int main (){ int a,b,c,k,count1,count2; for(a=4;a<=1200;a=a+2){ for(b=2;b ...