• 本帖最后由 604542720 于 2018-8-17 10:55 编辑 *

各位大佬们,我用的是lnmp1.5
反向代理的时候有个问题,如果是纯路径是可以代理过去的,但是如果后面跟了 .php 文件,就代理不过去了,显示404

配置文件如下,http://a.bbbb.com/tt/kk 这种是可以代理到的,但是如果是http://a.bbbb.com/tt/kk.php 就代理不过去了

server
{
listen 80;
#listen [::]:80;
server_name a.bbbb.com ;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/a.bbbb.com;

include rewrite/none.conf;
#error_page 404 /404.html;

# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

include enable-php.conf;

location / {
proxy_pass http://1.1.1.1;
}

location ~ /.well-known {
allow all;
}

location ~ /\.
{
deny all;
}

access_log /home/wwwlogs/a.bbbb.com.log;
}


搞定了,用这个

For nginx regexp locations have bigger priority than prefix locations. But

If the longest matching prefix location has the “^~” modifier then regular expressions are not checked.

So try to replace

**
location /rproxy/ {
**

with

**
location ^~ /rproxy/ {
**

Refer: https://stackoverflow.com/questions/29212655/nginx-php-scripts-not-being-called-from-reverse-proxy

我这边这么写就可以了

location ^~ / {
proxy_pass http://1.1.1.1;
}