首页
首页

为网站增加https访问

首先购买https服务,生成crt和key文件,nginx配置如下

server {
listen 443;
server_name blog.i-fanr.com;
index index.html index.htm index.php;
root /usr/share/nginx/blog.i-fanr.com;
add_header Access-Control-Allow-Origin *;

ssl on;
ssl_certificate /etc/nginx/ssl/blog.i-fanr.com.crt;
ssl_certificate_key /etc/nginx/ssl/blog.i-fanr.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;

if ($host = 'i-fanr.com') {
        rewrite ^/(.*) https://blog.i-fanr.com/$1 permanent;
}

if ($request_filename !~ (ico|js|css|img|fonts|downloads|helps|robots\.txt|index\.php)) {
        rewrite ^/(.*)$ /index.php/$1 last;
        break;
}

location ~ \.php {
        root /usr/share/nginx/blog.i-fanr.com;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        set $path_info "";
        set $real_script_name $fastcgi_script_name;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
}

}

支持一下
扫一扫,支持Timfan