nginx+php 开启https

nginx 配置如下,配置好重启nginx,不是nginx -s reload,如果还不能访问肯定就是防火墙问题,关闭防火墙再试试。

我遇到的问题是:我服务器是ecs,域名解析到阿里云复杂均衡的,结果怎么调试都不行,后来才知道阿里的负载均衡证书必须要在阿里上购买,其他的证书都不行,我把域名重新解析到ecs地址后就完全正常了。

server {
listen 80;
server_name fir.365yisu.com;
rewrite ^(.*)$ https://$host$1 permanent;
}
server {
listen 443 ssl http2;
server_name fir.365yisu.com;
access_log /var/log/nginx/fir-https_access.log main;
error_log /var/log/nginx/fir-https_error.log error;
ssl_certificate /data1/www/key/fir.pem;
ssl_certificate_key /data1/www/key/fir.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_session_cache shared:SSL:1m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
fastcgi_param HTTPS on;
fastcgi_param HTTP_SCHEME https;

location / {
index index.html index.php;
root /data1/www/fir;
}
location ~ \.php$ {
root /data1/www/fir; #指定php的根目录
fastcgi_pass 127.0.0.1:9000; #php-fpm的默认端口是9000
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

猜你喜欢

转载自www.cnblogs.com/abkn/p/9706097.html