1、上篇文章說了怎么在nginx開啟ssl模塊,開啟后怎么讓http強制跳轉到https
2、配置文件
#先監聽80端口,為http請求,然后強制轉發到https監聽的443端口上面
server {
listen 80;
root path;
server_name www.exp.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
#監聽443端口,https請求
server {
listen 443 ssl;
root path;
server_name www.exp.com;
ssl_certificate 證書文件.crt;
ssl_certificate_key 證書文件.key;
#此段代碼為rapidPHP單一入庫配置,不是rapidPHP框架請忽略
#location / {
# if (!-e $request_filename){
# rewrite ^(.*)$ /index.php?__ROUTE__=$1 last;
# }
#}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
配置完成重啟nginx即可
