一、如何将http升级到https

需要满足下面三个:

1.域名
2.nginx
3.SSL证书
    一般第三方证书颁发机构下发的证书是收费的,一年好几千。 
 
1) 从腾讯云申请免费的SSL证书,有效期一年,可申请多个 

SSL 证书申请地址在这里: https://console.qcloud.com/ssl
申请过程几分钟就可以搞定,主要分两步
1.申请免费的证书,设置手动DNS验证
2.到域名对应的域名解析商处添加解析记录 
下载申请好的域名,上传到服务器指定位置
2) nginx配置
2.1.使Nginx 支持 SSL
)检查 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
再次检查是否安装成功:
/usr/local/nginx/sbin/nginx -V 

2.2.编辑Nginx配置文件

cd /usr/local/nginx/conf
vim nginx.conf 
  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两种请求的更多相关文章

  1. nginx将http升级到https并且同时支持http和https两种请求、http自动转向https

    1.http升级到https 1.1.检查 Nginx 是否支持 SSL /usr/local/nginx/sbin/nginx -V configure arguments中是否有--with-ht ...

  2. Nginx 反向代理(http转htpps,并支持80端口继续提交post请求)

    项目是一个web server + 多个client的形式,client由用户安装在自己的电脑上 由http升级为https后,我们通过在Nginx做了80端口重定向443的配置,使用户通过访问htt ...

  3. nginx开启ssl并把http重定向到https的两种方式

    1 简介 Nginx是一个非常强大和流行的高性能Web服务器.本文讲解Nginx如何整合https并将http重定向到https. https相关文章如下: (1)Springboot整合https原 ...

  4. nginx 和 tp兼容pathinfo和rewrite两种url访问方式

    环境:centos7,yum安装的nginx1.10.php-fpm,tp3.2 本方法只需要配置nginx.conf的一个文件就可以支持pathinfo和rewrite两种url访问方式 vim / ...

  5. nginx、TP框架实现兼容pathinfo和rewrite两种url访问方式

    环境:centos7,yum安装的nginx1.10.php-fpm,tp3.2 本方法只需要配置nginx.conf的一个文件就可以支持pathinfo和rewrite两种url访问方式 vim / ...

  6. 配置nginx支持ssl服务器—HTTPS

    下文摘自: http://docs.bigbluebutton.org/install/install.html     Configuring HTTPS on BigBlueButtonAncho ...

  7. 源码安装nginx以及平滑升级

                                                           源码安装nginx以及平滑升级                               ...

  8. Nginx配置同一个域名同时支持http与https两种方式访问

    Nginx配置同一个域名http与https两种方式都可访问,证书是阿里云上免费申请的 server{listen 80;listen 443 ssl;ssl on;server_name 域名;in ...

  9. nginx的平滑升级

    一:解释nginx的平滑升级 随着nginx越来越流行,并且nginx的优势也越来越明显,nginx的版本迭代也来时加速模式,1.9.0版本的nginx更新了许多新功能,例如stream四层代理功能, ...

随机推荐

  1. nodejs网络编程

    通过NodeJS,除了可以编写一些服务端程序来协助前端开发和测试外,还能够学习一些HTTP协议与Socket协议的相关知识,这些知识在优化前端性能和排查前端故障时说不定能派上用场.本章将介绍与之相关的 ...

  2. CSS基础以及兼容IE方法

    1 介绍一下标准的CSS的盒子模型?与低版本IE的盒子模型有什么不同的? 标准盒子模型:宽度=内容的宽度(content)+ border + padding + margin低版本IE盒子模型:宽度 ...

  3. python3 获取日期时间

    #!/usr/bin/python3 import time # 格式化成2016-- ::39形式 print (time.strftime("%Y-%m-%d %H:%M:%S" ...

  4. oracle用dba创建用户并授权

    参考: https://blog.csdn.net/zhang195617/article/details/5857769 sqlplus中切换用户,如切换到adm用户,命令为:conn adm/12 ...

  5. javaWeb项目配置自定义404错误页

        1.情景展示 为了隐藏tomcat版本信息以及显示更友好的错误信息提示,如何将404的错误跳转到指定页面? 2.解决方案 第一步:修改项目的web.xml 将如下代码添加到</web-a ...

  6. 一些精简的JavaScript代码集合

    日历 创建过去七天的数组,如果将代码中的减号换成加号,你将得到未来7天的数组集合 // 创建过去七天的数组 [...Array(7).keys()].map(days => new Date(D ...

  7. linux 系统时间 EST CST

    早上本来要做一些实验的,基于时间的.date 查看时间,发现时间不对.用 pool.ntp.org 去同步发现时间还是一样的,并且没有报错.如是开启另外一台时间对的linux服务器进行对比.发现一个是 ...

  8. odoo前端必填提示

  9. django中配置使用celery

    环境版本: windows7 x64 django 1.11.6 django-celery 3.2.2 工程结构说明:源码下载请访问https://i.cnblogs.com/Files.aspx ...

  10. [转帖]How long does it take to make a context switch?

    How long does it take to make a context switch?   FROM: http://blog.tsunanet.net/2010/11/how-long-do ...