nginx启用https的注意和妥协支持http2及IE8以下版本http

星期四, 2017-06-01 | Author: Lee | JAVA-and-J2EE, linux | 3,615 views

站点启用https的支持后,IE8等低版本有一系列的问题(加载http等警告等),妥协是在IE8以下版本重定向到http去,
本文是基于nginx做的处理,支持http2协议,环境centos6.9

一: nginx-1.12.0 指定编译 openssl-1.0.2l.tar.gz及支持http2(openssl起1.0.2版本才支持)

二.重新编译nginx

1.核查版本
#sbin/nginx -V #查看版本
2.下载
#wget http://nginx.org/download/nginx-1.12.0.tar.gz #下载
#tar xzvf nginx-1.12.0.tar.gz #解压缩
#cd nginx-1.12.0
 
3.编译
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-openssl=/usr/local/webserver/openssl --with-http_ssl_module --with-pcre=/ia/data/tgz/pcre-8.32 --with-http_realip_module --with-http_image_filter_module --with-http_v2_module
 
#make
#mv /usr/local/webserver/nginx/sbin/nginx /usr/local/webserver/nginx/sbin/nginx.old #移动旧版本
#cp objs/nginx /usr/local/webserver/nginx/sbin/ #复制新版本nginx过去
 
4.启动新的,关掉旧的
让nginx把nginx.pid改成nginx.pid.oldbin 跟着启动新的nginx
# kill -USR2 `cat /usr/local/webserver/nginx/nginx.pid`
退出旧的nignx
# kill -QUIT `cat /usr/local/webserver/nginx/nginx.pid.oldbin
5.升级完成。
# sbin/nginx -V

三:(443端口)配置IE8以下版本重定向,(80端口)其他版本支持https

if ($http_user_agent !~* "MSIE [5-8].[0-9]") {
        rewrite (.*) https://www.iatodo.com$1 permanent;
        break;
    }
if ($http_user_agent ~* "MSIE [5-8].[0-9]") {
        rewrite (.*) http://www.iatodo.com$1 permanent;
        break;
    }

Tags: , ,

文章作者: Lee

本文地址: https://www.pomelolee.com/1727.html

除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址

No comments yet.

Leave a comment

Search

文章分类

Links

Meta