各位大神,小弟今天使用lnmp一键安装了nginx的环境, php是7.0+的。
上传laravel5.5的程序到服务器端,http访问正常。
配置https的时候出现了问题,找了很多资料都不行,求助啊!
小弟测试N久出来了两种问题:
第一种问题, 证书没问题, 但是网站不能访问:
问题1:
如果注释掉 include pathinfo.conf 这一行,-> 证书没问题, 但是报错 No input file specified.
问题2:
如果放开 include pathinfo.conf 这一行,-> 证书没问题, 但是报错404下图
第二种问题, 证书不行, 但网站可以访问
问题: 如果把index 和 root 这2行放到 location / 外面 网站可以了,但是证书不行, 反之放进来证书可以了,网站不行了
所有代码
server {
listen 443 ssl;
server_name www.baidu.com;
ssl on;
ssl_certificate /cn_bundle.crt;
ssl_certificate_key /cn.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
#禁止在header中出现服务器版本,防止黑客利用版本漏洞攻击
server_tokens off;
#如果是全站 HTTPS 并且不考虑 HTTP 的话,可以加入 HSTS 告诉你的浏览器本网站全站加密,并且强>制用 HTTPS 访问
#add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
# ......
#fastcgi_param HTTPS on;
#fastcgi_param HTTP_SCHEME https;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
index index.html index.htm index.php default.html default.htm default.php forum.php;
root /home/wwwroot/default/laravel/public;
try_files $uri $uri/ /index.php?$query_string;
}
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
#try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
# include pathinfo.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
}
使用的腾讯云的免费证书。望大神给与指点。
root和index 放到server 域,就是location 外面,不然,你下面的所有location域都找不到 网站根目录在哪里。
下面的if条件判断是为了啥啊? try_files 和 !-e 下面的逻辑不一样,你到底需要哪一个?把需要得改成 try_files 的格式,放到location /下去。
然后放开 pathinfo.conf的引入 。。