ngix+apache下https配置

来源:互联网 发布:mac 应用程序 身份不明 编辑:程序博客网 时间:2024/06/07 04:35

环境:wdcp+ngix+apache

ngix同时支持http和https:

1.下载证书,将证书文件放到 /www/wdlinux/nginx/conf目录下

2.修改ngix配置文件
 /www/wdlinux/nginx/conf/vhost/www.xxxxxxx.com.conf

server {
        listen       80;
        listen 443 ssl;
        root /网站目录;
        server_name 域名;
        index  index.html index.php index.htm;
        ssl_certificate zhengshu.crt;
        ssl_certificate_key zhengshu.key;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout 10m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;
        .

.

.
}

3.测试无误并重启web服务

/www/wdlinux/nginx/sbin/nginx -t


4.HTTPS服务器优化

cd /www/wdlinux/nginx/conf/

vi nginx.conf

参考:http://blog.csdn.net/mr_raptor/article/details/51854746


5.单页面中配置http自动跳转https方法
在需要强制为https的页面上加入该代码进行处理
<script type=”text/javascript”>
var url = window.location.href;
if (url.indexOf(“https”) < 0) {
url = url.replace(“http:”, “https:”);
window.location.replace(url);
}
</script>


参考:

http://www.cnblogs.com/phpper/p/6441475.html

https://cloud.tencent.com/document/product/400/4143

http://blog.csdn.net/weixin_35884835/article/details/52588157

http://blog.csdn.net/na_tion/article/details/17334669

http://www.cnblogs.com/wjoyxt/p/6102172.html

原创粉丝点击