咨询热线:4006-75-4006

售前:9:00-23:30    备案:9:00-18:00    技术:7*24h

nginx如何绑定ssl证书

2017-11-27 17:48:38 26430次

1.其实非常简单,原理就是建立好网站后在配置文件中引入ssl证书文件,如下

listen 443 ssl;
ssl    on;
ssl_certificate /home/wwwroot/www.landui.com/ssl/Nginx/www.landui.com_ssl.crt;
ssl_certificate_key /home/wwwroot/www.landui.com/ssl/Nginx/www.landui.com_ssl.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;

image.png
 2.做301从http跳转到https

if ($ssl_protocol=""){return 301 https://$host$request_uri;}
        if ($host !=www.landui.com) {return 301 $scheme://www.landui.com$request_uri;}
        location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv|mp4)$ {
                valid_referers none blocked *.xn--eqvw44d.com www.landui.com xn--eqvw44d.com;
                if ($invalid_referer){
                        rewrete ^/ http://www.landui.com/403.html;
                        return 403;
                }
        }

image.png
 2.测试访问
image.png

首页
最新活动
个人中心