- A+
所属分类:网页技术
废话不多说,直接开始:
1.安装Nginx,这里就不表述了。
2.申请SSL免费证书,阿里云、腾讯云、百度云等都提供免费SSL单域名证书申请。
3.申请后下载Nginx配套的证书,即后缀名为.pem和.key的两个文件。
4.配置Nginx支持HTTPS访问:
server {
listen 80;
listen 443 ssl http2;
server_name www.xx.com; #改为绑定证书的域名
#强制HTTP到HTTPS访问
if ($scheme = http)
{
return 301 https://$server_name$request_uri;
}
root /root/www; #站点目录
index index.php index.html index.htm;
ssl_certificate /root/www/domain.pem;
ssl_certificate_key /root/www/domain.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;
location / {
root /root/www; #站点目录
index index.php index.html index.htm;
if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
proxy_connect_timeout 1;
proxy_send_timeout 30;
proxy_read_timeout 60;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /root/www;
}
location ~ \.php {
root /root/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
#fastcgi_connect_timeout 999999; #增加超时
#fastcgi_send_timeout 999999; #增加超时
#fastcgi_read_timeout 999999; #增加超时
fastcgi_split_path_info ^(.+\.php)(.*)$; #增加这一句
fastcgi_param PATH_INFO $fastcgi_path_info; #增加这一句
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
5.在Cloudflare网站(https://www.cloudflare.com/)申请并提交域名。
6.将域名的DNS服务器设置为Cloudflare服务器。
7.将cloudflare所对应域名中crypto的SSL设置为Full(strict) 。
8.配制FRP开启80和443端口。
9.启动Nginx和FRP服务即可。