首先是一点背景。我的nginx配置中有一些无扩展名的文件,它们被定向到一个php文件,例如:
/ galleries / 1/17/22调用/galleries.php?mypath=$mypath&$args
图库位置try_files还会检查是否存在静态版本。这在我之前的CentOS服务器上运行良好多年,但我正在迁移到Ubuntu服务器,突然间,如果有人调用/ gallery /,我会收到502 Bad Gateway错误。没有尾部斜杠的调用/画廊没有问题。
首先,这是位置:
location ~ ^/galleries(?P<mypath>/.*$|$) {
error_log /var/log/nginx/galerrors.log debug;
try_files /pixcache$request_uri/index.html /galleries.php?mypath=$mypath&$args;
fastcgi_pass 127.0.0.1:9000;
}
如果有人打电话,比如/ galleries / 51/646/31,调试日志会显示:
trying to use file: "/pixcache/galleries/51/646/31/index.html"
"/usr/share/nginx/html/pixcache/galleries/51/646/31/index.html"
如果找不到静态版本调试显示:
trying to use file: "/galleries.php?mypath=/51/646/31&"
"/usr/share/nginx/html/galleries.php?mypath=/51/646/31&"
一切正常。但是,如果有人试图使用/ galleries /调用主页面,我们会得到:
trying to use file: "/pixcache/galleries//index.html"
"/usr/share/nginx/html/pixcache/galleries//index.html"
trying to use file: "/galleries.php?mypath=/&"
"/usr/share/nginx/html/galleries.php?mypath=/&"
请注意静态文件检查中的双斜线“//”,动态胆量正在丢失坏网关。旧服务器运行良好多年这个位置,所以我真的在这里刮我的头。我已经盯着它好几个小时了。我吮吸正则表达式,但这可能与它有关吗?