#########http###########
server{
listen 80; #监听的端口号
server_name pazzn.com www.pazzn.com; #您的域名
return 301 https://www.pazzn.com$request_uri; ####强制将80端口的流量跳转到这个https指定网址
location / {
root /home/www/pazzn; #站点的路径
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
}
location ~ ^.+.php {
root /home/www/pazzn; #站点的路径
fastcgi_pass 127.0.0.1:9000; #根据自己的 php-fpm 配置填写
fastcgi_index index.php;
###配置支持pathinfo
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
###########https####
server{
listen 443; #监听的端口号
server_name www.pazzn.com; #您的域名
ssl on;
ssl_certificate /etc/letsencrypt/live/www.pazzn.com/fullchain.pem; ###其他沃通申请的证书在nginx也是改这个路径
ssl_certificate_key /etc/letsencrypt/live/www.pazzn.com/privkey.pem; ###其他沃通申请的证书在nginx也是改这个路径
location / {
root /home/www/pazzn; #站点的路径
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
}
location ~ ^.+.php {
root /home/www/pazzn; #站点的路径
fastcgi_pass 127.0.0.1:9000; #根据自己的 php-fpm 配置填写
fastcgi_index index.php;
###配置支持pathinfo
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
证书连接:https://www.qikqiak.com/post/make-https-blog/