Nginx网站环境配置SSL安全证书方法

搬瓦工机场JMS

这几天公司的几个客户网站有要求安装SSL安全证书,从原来的HTTP变成HTTPS地址访问网站,于是对于这方面的SSL证书教程还是需要有所研究的。无论我们采用Let's Encrypt免费证书,还是付费证书,我们搭建的方法都是差不多的,最为主要的是安装到网站环境中,这里我采用的是NGINX环境。

Nginx网站环境配置SSL安全证书方法

server {
    listen 80;
    server_name banwagong.me www.banwagong.me; #替换为自己的域名
    rewrite ^/(.*) https://$server_name/$1 permanent;
}
server {
    listen 443 ssl;
    ssl on;
    ssl_certificate /root/ssl/banwagongme_certificate;    #替换我们自己的SSL证书路径
    ssl_certificate_key /root/ssl/banwagongme_privatekey; #替换我们自己的SSL密钥路径
    ssl_session_timeout 10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;
    ssl_session_cache builtin:1000 shared:SSL:10m;
    root /var/www/banwagong.me;              #网站目录
        index index.php index.html index.htm;
        server_name banwagong.me www.banwagong.me; #替换域名
 
    location / {
        include wordpress.conf;          #伪静态规则
        }
  location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }   
}

我们需要在自己当前站点.CONF文件中替换上面对应的文件和配置SSL证书和密钥的路径。最后我们重启NGINX就可以生效,网站就被加入SSL证书,而且全部变成HTTPS地址。

未经允许不得转载:搬瓦工VPS_美国VPS » Nginx网站环境配置SSL安全证书方法

赞 (0) 打赏

相关推荐

    暂无内容!

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏