Nginx 配置HTTPS证书

Nginx 配置HTTPS证书

申请阿里云免费证书

申请免费证书.jpg

下载证书到本地

下载证书到本地.jpg

上传证书到服务器

/usr/local/nginx/conf/cert
上传证书到服务器.jpg

修改Nginx配置,开启SSL

server
{
    listen 443;
    server_name mrtable.cn;

    ssl on;
    ssl_certificate   cert/mrtable.pem;
    ssl_certificate_key  cert/mrtable.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;

    index index.html index.htm index.php default.html default.htm default.php;
    root  /home/wwwroot/www.mrtable.cn;

    include wordpress.conf;

    location ~ [^/]\.php(/|$)
    {
        try_files $uri =404;
        fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_index index.php;
        include fastcgi.conf;   
    }
}

server
{
    listen       80;
    server_name mrtable.cn *.mrtable.cn;
    location /{
        rewrite ^(.*)$ https://mrtable.cn$1 permanent;
    }
}

重启 Nginx

/etc/init.d/nginx restart

发表评论