nginx+php 开启https

Posted abkn

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
}
}

技术分享图片

 

以上是关于nginx+php 开启https的主要内容,如果未能解决你的问题,请参考以下文章

Nginx Https 配置

使用zabbix监控php-fpm服务(十六)

lanmp之一 (动静分离)

php笔试题--转载

PHP 面试题三

倒腾HTTPSNginx for Docker自签名SSL证书