首先,你得先把https配置好 Nginx下配置网站SSL实现https访问(虚拟主机)
然后在nginx文件夹下找到对应的虚拟主机配置文件,路径为:www/haozilinux/nginx/conf/vhost
然后对该虚拟主机配置文件做如下修改:
server {
listen 443;
root /www/web/fuyulife/public_html;
server_name www.fuwenhao.com www.fuwenhao.com;
index index.html index.php index.htm;
error_page 400 /errpage/400.html;
error_page 403 /errpage/403.html;
error_page 404 /errpage/404.html;
error_page 503 /errpage/503.html;
ssl on;
ssl_certificate_key /www/haozilinux/nginx/conf/fuwenhao.key;
ssl_certificate /www/haozilinux/nginx/conf/fuwenhao.crt;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ /\.ht {
deny all;
}
include /www/haozilinux/wdcp/rewrite/dzx32_nginx.conf;
}
server {
listen 80;
server_name www.fuwenhao.com;
return 301 https://$server_name$request_uri;
}
蓝色部分为rewrite规则,原理是监听443端口使用https,监听80端口使用301重定向到https.
还没有评论,来说两句吧...