NGINX不使用fast_cgi将php下载为文件

时间:2016-11-22 22:39:07

标签: php nginx

我有一个NGINX站点配置,它提供来自通配符子目录的文件,并将URI传递给该目录中index.php文件的查询字符串。

我已经设置了调试,似乎它能够找到正确的目录和index.php文件,但从不为附带查询字符串的index.php文件提供服务。它只是下载我的PHP文件。

这是我的NGINX配置文件:

server {
listen 80 default_server;
listen 443 ssl;

    root /var/www;

    server_name <my ip address>; 

index index.php index.html index.htm;
autoindex on;

location /dev {
        autoindex on;
    }

location ~ ^/dev/(?<portal>[^/]+)(?<theRest>.*) {
   try_files $uri $uri/ /dev/$portal/index.php?_url=$uri;
}

    location /assets {
       # try_files $uri $uri/;
        autoindex on;
    }

    location /opn {
        try_files $uri $uri/ /opn/index.php?_url=/$uri;
        autoindex on;
    }

location ~ \.php$ {

    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
}

client_body_buffer_size     90M;
client_max_body_size        100M;

}

我从调试日志中得到以下信息:

2016/11/22 21:50:11 [debug] 1849#0: post event 00000000025DC630
2016/11/22 21:50:11 [debug] 1849#0: delete posted event 00000000025DC630
2016/11/22 21:50:11 [debug] 1849#0: accept on 0.0.0.0:80, ready: 0
2016/11/22 21:50:11 [debug] 1849#0: posix_memalign: 00000000025A7980:256 @16
2016/11/22 21:50:11 [debug] 1849#0: *1 accept: 172.56.39.58 fd:10
2016/11/22 21:50:11 [debug] 1849#0: posix_memalign: 00000000025C8B90:256 @16
2016/11/22 21:50:11 [debug] 1849#0: *1 event timer add: 10: 60000:1479851471914
2016/11/22 21:50:11 [debug] 1849#0: *1 reusable connection: 1
2016/11/22 21:50:11 [debug] 1849#0: *1 epoll add event: fd:10 op:1 ev:80002001
2016/11/22 21:50:11 [debug] 1849#0: post event 00000000025DC630
2016/11/22 21:50:11 [debug] 1849#0: *1 post event 00000000025DC768
2016/11/22 21:50:11 [debug] 1849#0: delete posted event 00000000025DC630
2016/11/22 21:50:11 [debug] 1849#0: accept on 0.0.0.0:80, ready: 0
2016/11/22 21:50:11 [debug] 1849#0: posix_memalign: 00000000025C8CA0:256 @16
2016/11/22 21:50:11 [debug] 1849#0: *2 accept: 172.56.39.58 fd:12
2016/11/22 21:50:11 [debug] 1849#0: posix_memalign: 00000000025C8DB0:256 @16
2016/11/22 21:50:11 [debug] 1849#0: *2 event timer add: 12: 60000:1479851471920
2016/11/22 21:50:11 [debug] 1849#0: *2 reusable connection: 1
2016/11/22 21:50:11 [debug] 1849#0: *2 epoll add event: fd:12 op:1 ev:80002001
2016/11/22 21:50:11 [debug] 1849#0: *1 delete posted event 00000000025DC768
2016/11/22 21:50:11 [debug] 1849#0: *1 http wait request handler
2016/11/22 21:50:11 [debug] 1849#0: *1 malloc: 00000000025C8EC0:1024
2016/11/22 21:50:11 [debug] 1849#0: *1 recv: fd:10 423 of 1024
2016/11/22 21:50:11 [debug] 1849#0: *1 reusable connection: 0
2016/11/22 21:50:11 [debug] 1849#0: *1 posix_memalign: 00000000025C2950:4096 @16
2016/11/22 21:50:11 [debug] 1849#0: *1 http process request line
2016/11/22 21:50:11 [debug] 1849#0: *1 http request line: "GET /dev/portal HTTP/1.1"
2016/11/22 21:50:11 [debug] 1849#0: *1 http uri: "/dev/portal"
2016/11/22 21:50:11 [debug] 1849#0: *1 http args: ""
2016/11/22 21:50:11 [debug] 1849#0: *1 http exten: ""
2016/11/22 21:50:11 [debug] 1849#0: *1 posix_memalign: 00000000025B5250:4096 @16
2016/11/22 21:50:11 [debug] 1849#0: *1 http process request header line
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "Connection: keep-alive"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "Upgrade-Insecure-Requests: 1"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "Accept-Encoding: gzip, deflate, sdch"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "Accept-Language: en-US,en;q=0.8"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "Cookie: PHPSESSID=jpi52v69f09p9f0aaqhtkvcgm3"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header done
2016/11/22 21:50:11 [debug] 1849#0: *1 event timer del: 10: 1479851471914
2016/11/22 21:50:11 [debug] 1849#0: *1 generic phase: 0
2016/11/22 21:50:11 [debug] 1849#0: *1 rewrite phase: 1
2016/11/22 21:50:11 [debug] 1849#0: *1 test location: "/dev"
2016/11/22 21:50:11 [debug] 1849#0: *1 test location: ~ "^/dev/(?<portal>[^/]+)(?<theRest>.*)"
2016/11/22 21:50:11 [debug] 1849#0: *1 http regex set $portal to "portal"
2016/11/22 21:50:11 [debug] 1849#0: *1 http regex set $therest to ""
2016/11/22 21:50:11 [debug] 1849#0: *1 using configuration "^/dev/(?<portal>[^/]+)(?<theRest>.*)"
2016/11/22 21:50:11 [debug] 1849#0: *1 http cl:-1 max:104857600
2016/11/22 21:50:11 [debug] 1849#0: *1 rewrite phase: 3
2016/11/22 21:50:11 [debug] 1849#0: *1 post rewrite phase: 4
2016/11/22 21:50:11 [debug] 1849#0: *1 generic phase: 5
2016/11/22 21:50:11 [debug] 1849#0: *1 generic phase: 6
2016/11/22 21:50:11 [debug] 1849#0: *1 generic phase: 7
2016/11/22 21:50:11 [debug] 1849#0: *1 access phase: 8
2016/11/22 21:50:11 [debug] 1849#0: *1 access phase: 9
2016/11/22 21:50:11 [debug] 1849#0: *1 access phase: 10
2016/11/22 21:50:11 [debug] 1849#0: *1 access phase: 11
2016/11/22 21:50:11 [debug] 1849#0: *1 post access phase: 12
2016/11/22 21:50:11 [debug] 1849#0: *1 try files phase: 13
2016/11/22 21:50:11 [debug] 1849#0: *1 http script var: "/dev/portal"
2016/11/22 21:50:11 [debug] 1849#0: *1 trying to use file: "/dev/portal" "/var/www/dev/portal"
2016/11/22 21:50:11 [debug] 1849#0: *1 http script var: "/dev/portal"
2016/11/22 21:50:11 [debug] 1849#0: *1 trying to use dir: "/dev/portal" "/var/www/dev/portal"
2016/11/22 21:50:11 [debug] 1849#0: *1 try file uri: "/dev/portal"
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 14
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 15
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 16
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 17
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 18
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 19
2016/11/22 21:50:11 [debug] 1849#0: *1 http filename: "/var/www/dev/portal"
2016/11/22 21:50:11 [debug] 1849#0: *1 add cleanup: 00000000025C3798
2016/11/22 21:50:11 [debug] 1849#0: *1 http static fd: -1
2016/11/22 21:50:11 [debug] 1849#0: *1 http dir
2016/11/22 21:50:11 [debug] 1849#0: *1 http finalize request: 301, "/dev/portal?" a:1, c:1
2016/11/22 21:50:11 [debug] 1849#0: *1 http special response: 301, "/dev/portal?"
2016/11/22 21:50:11 [debug] 1849#0: *1 http set discard body
2016/11/22 21:50:11 [debug] 1849#0: *1 xslt filter header
2016/11/22 21:50:11 [debug] 1849#0: *1 HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.2
Date: Tue, 22 Nov 2016 21:50:11 GMT
Content-Type: text/html
Content-Length: 184
Location: http://104.196.238.47/dev/portal/
Connection: keep-alive

2016/11/22 21:50:11 [debug] 1849#0: *1 write new buf t:1 f:0 00000000025C3848, pos 00000000025C3848, size: 207 file: 0, size: 0
2016/11/22 21:50:11 [debug] 1849#0: *1 http write filter: l:0 f:0 s:207
2016/11/22 21:50:11 [debug] 1849#0: *1 http output filter "/dev/portal?"
2016/11/22 21:50:11 [debug] 1849#0: *1 http copy filter: "/dev/portal?"
2016/11/22 21:50:11 [debug] 1849#0: *1 image filter
2016/11/22 21:50:11 [debug] 1849#0: *1 xslt filter body
2016/11/22 21:50:11 [debug] 1849#0: *1 http postpone filter "/dev/portal?" 00000000025C3940
2016/11/22 21:50:11 [debug] 1849#0: *1 write old buf t:1 f:0 00000000025C3848, pos 00000000025C3848, size: 207 file: 0, size: 0
2016/11/22 21:50:11 [debug] 1849#0: *1 write new buf t:0 f:0 0000000000000000, pos 00000000006DDAC0, size: 132 file: 0, size: 0
2016/11/22 21:50:11 [debug] 1849#0: *1 write new buf t:0 f:0 0000000000000000, pos 00000000006DDDA0, size: 52 file: 0, size: 0
2016/11/22 21:50:11 [debug] 1849#0: *1 http write filter: l:1 f:0 s:391
2016/11/22 21:50:11 [debug] 1849#0: *1 http write filter limit 0
2016/11/22 21:50:11 [debug] 1849#0: *1 writev: 391
2016/11/22 21:50:11 [debug] 1849#0: *1 http write filter 0000000000000000
2016/11/22 21:50:11 [debug] 1849#0: *1 http copy filter: 0 "/dev/portal?"
2016/11/22 21:50:11 [debug] 1849#0: *1 http finalize request: 0, "/dev/portal?" a:1, c:1
2016/11/22 21:50:11 [debug] 1849#0: *1 set http keepalive handler
2016/11/22 21:50:11 [debug] 1849#0: *1 http close request
2016/11/22 21:50:11 [debug] 1849#0: *1 http log handler
2016/11/22 21:50:11 [debug] 1849#0: *1 free: 00000000025C2950, unused: 0
2016/11/22 21:50:11 [debug] 1849#0: *1 free: 00000000025B5250, unused: 2566
2016/11/22 21:50:11 [debug] 1849#0: *1 free: 00000000025C8EC0
2016/11/22 21:50:11 [debug] 1849#0: *1 hc free: 0000000000000000 0
2016/11/22 21:50:11 [debug] 1849#0: *1 hc busy: 0000000000000000 0
2016/11/22 21:50:11 [debug] 1849#0: *1 tcp_nodelay
2016/11/22 21:50:11 [debug] 1849#0: *1 reusable connection: 1
2016/11/22 21:50:11 [debug] 1849#0: *1 event timer add: 10: 65000:1479851476920
2016/11/22 21:50:11 [debug] 1849#0: *1 post event 00000000025DC768
2016/11/22 21:50:11 [debug] 1849#0: *1 delete posted event 00000000025DC768
2016/11/22 21:50:11 [debug] 1849#0: *1 http keepalive handler
2016/11/22 21:50:11 [debug] 1849#0: *1 malloc: 00000000025C8EC0:1024
2016/11/22 21:50:11 [debug] 1849#0: *1 recv: fd:10 -1 of 1024
2016/11/22 21:50:11 [debug] 1849#0: *1 recv() not ready (11: Resource temporarily unavailable)
2016/11/22 21:50:11 [debug] 1849#0: *1 free: 00000000025C8EC0
2016/11/22 21:50:11 [debug] 1849#0: post event 00000000025DC630
2016/11/22 21:50:11 [debug] 1849#0: delete posted event 00000000025DC630
2016/11/22 21:50:11 [debug] 1849#0: accept on 0.0.0.0:80, ready: 0
2016/11/22 21:50:11 [debug] 1849#0: posix_memalign: 00000000025C8EC0:256 @16
2016/11/22 21:50:11 [debug] 1849#0: *3 accept: 172.56.39.58 fd:14
2016/11/22 21:50:11 [debug] 1849#0: posix_memalign: 00000000025C8FD0:256 @16
2016/11/22 21:50:11 [debug] 1849#0: *3 event timer add: 14: 60000:1479851471921
2016/11/22 21:50:11 [debug] 1849#0: *3 reusable connection: 1
2016/11/22 21:50:11 [debug] 1849#0: *3 epoll add event: fd:14 op:1 ev:80002001
2016/11/22 21:50:11 [debug] 1849#0: *1 post event 00000000025DC768
2016/11/22 21:50:11 [debug] 1849#0: *1 delete posted event 00000000025DC768
2016/11/22 21:50:11 [debug] 1849#0: *1 http keepalive handler
2016/11/22 21:50:11 [debug] 1849#0: *1 malloc: 00000000025C90E0:1024
2016/11/22 21:50:11 [debug] 1849#0: *1 recv: fd:10 424 of 1024
2016/11/22 21:50:11 [debug] 1849#0: *1 reusable connection: 0
2016/11/22 21:50:11 [debug] 1849#0: *1 posix_memalign: 00000000025C2950:4096 @16
2016/11/22 21:50:11 [debug] 1849#0: *1 event timer del: 10: 1479851476920
2016/11/22 21:50:11 [debug] 1849#0: *1 http process request line
2016/11/22 21:50:11 [debug] 1849#0: *1 http request line: "GET /dev/portal/ HTTP/1.1"
2016/11/22 21:50:11 [debug] 1849#0: *1 http uri: "/dev/portal/"
2016/11/22 21:50:11 [debug] 1849#0: *1 http args: ""
2016/11/22 21:50:11 [debug] 1849#0: *1 http exten: ""
2016/11/22 21:50:11 [debug] 1849#0: *1 posix_memalign: 00000000025B5250:4096 @16
2016/11/22 21:50:11 [debug] 1849#0: *1 http process request header line
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "Connection: keep-alive"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "Upgrade-Insecure-Requests: 1"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "Accept-Encoding: gzip, deflate, sdch"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "Accept-Language: en-US,en;q=0.8"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header: "Cookie: PHPSESSID=jpi52v69f09p9f0aaqhtkvcgm3"
2016/11/22 21:50:11 [debug] 1849#0: *1 http header done
2016/11/22 21:50:11 [debug] 1849#0: *1 generic phase: 0
2016/11/22 21:50:11 [debug] 1849#0: *1 rewrite phase: 1
2016/11/22 21:50:11 [debug] 1849#0: *1 test location: "/dev"
2016/11/22 21:50:11 [debug] 1849#0: *1 test location: ~ "^/dev/(?<portal>[^/]+)(?<theRest>.*)"
2016/11/22 21:50:11 [debug] 1849#0: *1 http regex set $portal to "portal"
2016/11/22 21:50:11 [debug] 1849#0: *1 http regex set $therest to "/"
2016/11/22 21:50:11 [debug] 1849#0: *1 using configuration "^/dev/(?<portal>[^/]+)(?<theRest>.*)"
2016/11/22 21:50:11 [debug] 1849#0: *1 http cl:-1 max:104857600
2016/11/22 21:50:11 [debug] 1849#0: *1 rewrite phase: 3
2016/11/22 21:50:11 [debug] 1849#0: *1 post rewrite phase: 4
2016/11/22 21:50:11 [debug] 1849#0: *1 generic phase: 5
2016/11/22 21:50:11 [debug] 1849#0: *1 generic phase: 6
2016/11/22 21:50:11 [debug] 1849#0: *1 generic phase: 7
2016/11/22 21:50:11 [debug] 1849#0: *1 access phase: 8
2016/11/22 21:50:11 [debug] 1849#0: *1 access phase: 9
2016/11/22 21:50:11 [debug] 1849#0: *1 access phase: 10
2016/11/22 21:50:11 [debug] 1849#0: *1 access phase: 11
2016/11/22 21:50:11 [debug] 1849#0: *1 post access phase: 12
2016/11/22 21:50:11 [debug] 1849#0: *1 try files phase: 13
2016/11/22 21:50:11 [debug] 1849#0: *1 http script var: "/dev/portal/"
2016/11/22 21:50:11 [debug] 1849#0: *1 trying to use file: "/dev/portal/" "/var/www/dev/portal/"
2016/11/22 21:50:11 [debug] 1849#0: *1 http script var: "/dev/portal/"
2016/11/22 21:50:11 [debug] 1849#0: *1 trying to use dir: "/dev/portal/" "/var/www/dev/portal/"
2016/11/22 21:50:11 [debug] 1849#0: *1 try file uri: "/dev/portal/"
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 14
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 15
2016/11/22 21:50:11 [debug] 1849#0: *1 open index "/var/www/dev/portal/index.php"
2016/11/22 21:50:11 [debug] 1849#0: *1 internal redirect: "/dev/portal/index.php?"
2016/11/22 21:50:11 [debug] 1849#0: *1 rewrite phase: 1
2016/11/22 21:50:11 [debug] 1849#0: *1 test location: "/dev"
2016/11/22 21:50:11 [debug] 1849#0: *1 test location: ~ "^/dev/(?<portal>[^/]+)(?<theRest>.*)"
2016/11/22 21:50:11 [debug] 1849#0: *1 http regex set $portal to "portal"
2016/11/22 21:50:11 [debug] 1849#0: *1 http regex set $therest to "/index.php"
2016/11/22 21:50:11 [debug] 1849#0: *1 using configuration "^/dev/(?<portal>[^/]+)(?<theRest>.*)"
2016/11/22 21:50:11 [debug] 1849#0: *1 http cl:-1 max:104857600
2016/11/22 21:50:11 [debug] 1849#0: *1 rewrite phase: 3
2016/11/22 21:50:11 [debug] 1849#0: *1 post rewrite phase: 4
2016/11/22 21:50:11 [debug] 1849#0: *1 generic phase: 5
2016/11/22 21:50:11 [debug] 1849#0: *1 generic phase: 6
2016/11/22 21:50:11 [debug] 1849#0: *1 generic phase: 7
2016/11/22 21:50:11 [debug] 1849#0: *1 access phase: 8
2016/11/22 21:50:11 [debug] 1849#0: *1 access phase: 9
2016/11/22 21:50:11 [debug] 1849#0: *1 access phase: 10
2016/11/22 21:50:11 [debug] 1849#0: *1 access phase: 11
2016/11/22 21:50:11 [debug] 1849#0: *1 post access phase: 12
2016/11/22 21:50:11 [debug] 1849#0: *1 try files phase: 13
2016/11/22 21:50:11 [debug] 1849#0: *1 http script var: "/dev/portal/index.php"
2016/11/22 21:50:11 [debug] 1849#0: *1 trying to use file: "/dev/portal/index.php" "/var/www/dev/portal/index.php"
2016/11/22 21:50:11 [debug] 1849#0: *1 try file uri: "/dev/portal/index.php"
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 14
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 15
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 16
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 17
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 18
2016/11/22 21:50:11 [debug] 1849#0: *1 content phase: 19
2016/11/22 21:50:11 [debug] 1849#0: *1 http filename: "/var/www/dev/portal/index.php"
2016/11/22 21:50:11 [debug] 1849#0: *1 add cleanup: 00000000025C37F0
2016/11/22 21:50:11 [debug] 1849#0: *1 http static fd: 15
2016/11/22 21:50:11 [debug] 1849#0: *1 http set discard body
2016/11/22 21:50:11 [debug] 1849#0: *1 xslt filter header
2016/11/22 21:50:11 [debug] 1849#0: *1 HTTP/1.1 200 OK
Server: nginx/1.6.2
Date: Tue, 22 Nov 2016 21:50:11 GMT
Content-Type: application/octet-stream
Content-Length: 325
Last-Modified: Mon, 21 Nov 2016 21:43:13 GMT
Connection: keep-alive
ETag: "58336a71-145"
Accept-Ranges: bytes

2016/11/22 21:50:11 [debug] 1849#0: *1 write new buf t:1 f:0 00000000025B56F8, pos 00000000025B56F8, size: 252 file: 0, size: 0
2016/11/22 21:50:11 [debug] 1849#0: *1 http write filter: l:0 f:0 s:252
2016/11/22 21:50:11 [debug] 1849#0: *1 http output filter "/dev/portal/index.php?"
2016/11/22 21:50:11 [debug] 1849#0: *1 http copy filter: "/dev/portal/index.php?"
2016/11/22 21:50:11 [debug] 1849#0: *1 image filter
2016/11/22 21:50:11 [debug] 1849#0: *1 xslt filter body
2016/11/22 21:50:11 [debug] 1849#0: *1 http postpone filter "/dev/portal/index.php?" 00007FFF4B2638E0
2016/11/22 21:50:11 [debug] 1849#0: *1 write old buf t:1 f:0 00000000025B56F8, pos 00000000025B56F8, size: 252 file: 0, size: 0
2016/11/22 21:50:11 [debug] 1849#0: *1 write new buf t:0 f:1 0000000000000000, pos 0000000000000000, size: 0 file: 0, size: 325
2016/11/22 21:50:11 [debug] 1849#0: *1 http write filter: l:1 f:0 s:577
2016/11/22 21:50:11 [debug] 1849#0: *1 http write filter limit 0
2016/11/22 21:50:11 [debug] 1849#0: *1 no tcp_nodelay
2016/11/22 21:50:11 [debug] 1849#0: *1 tcp_nopush
2016/11/22 21:50:11 [debug] 1849#0: *1 writev: 252
2016/11/22 21:50:11 [debug] 1849#0: *1 sendfile: @0 325
2016/11/22 21:50:11 [debug] 1849#0: *1 sendfile: 325, @0 325:325
2016/11/22 21:50:11 [debug] 1849#0: *1 http write filter 0000000000000000
2016/11/22 21:50:11 [debug] 1849#0: *1 http copy filter: 0 "/dev/portal/index.php?"
2016/11/22 21:50:11 [debug] 1849#0: *1 http finalize request: 0, "/dev/portal/index.php?" a:1, c:2
2016/11/22 21:50:11 [debug] 1849#0: *1 http request count:2 blk:0
2016/11/22 21:50:11 [debug] 1849#0: *1 http finalize request: -4, "/dev/portal/index.php?" a:1, c:1
2016/11/22 21:50:11 [debug] 1849#0: *1 set http keepalive handler
2016/11/22 21:50:11 [debug] 1849#0: *1 http close request
2016/11/22 21:50:11 [debug] 1849#0: *1 http log handler
2016/11/22 21:50:11 [debug] 1849#0: *1 run cleanup: 00000000025C37F0
2016/11/22 21:50:11 [debug] 1849#0: *1 file cleanup: fd:15
2016/11/22 21:50:11 [debug] 1849#0: *1 free: 00000000025C2950, unused: 40
2016/11/22 21:50:11 [debug] 1849#0: *1 free: 00000000025B5250, unused: 2301
2016/11/22 21:50:11 [debug] 1849#0: *1 free: 00000000025C90E0
2016/11/22 21:50:11 [debug] 1849#0: *1 hc free: 0000000000000000 0
2016/11/22 21:50:11 [debug] 1849#0: *1 hc busy: 0000000000000000 0
2016/11/22 21:50:11 [debug] 1849#0: *1 reusable connection: 1
2016/11/22 21:50:11 [debug] 1849#0: *1 event timer add: 10: 65000:1479851476992
2016/11/22 21:50:11 [debug] 1849#0: *1 post event 00000000025DC768
2016/11/22 21:50:11 [debug] 1849#0: *1 delete posted event 00000000025DC768
2016/11/22 21:50:11 [debug] 1849#0: *1 http keepalive handler
2016/11/22 21:50:11 [debug] 1849#0: *1 malloc: 00000000025C90E0:1024
2016/11/22 21:50:11 [debug] 1849#0: *1 recv: fd:10 -1 of 1024
2016/11/22 21:50:11 [debug] 1849#0: *1 recv() not ready (11: Resource temporarily unavailable)
2016/11/22 21:50:11 [debug] 1849#0: *1 free: 00000000025C90E0

1 个答案:

答案 0 :(得分:0)

阅读this document,了解nginx如何选择用于处理请求的location块。

在您的情况下,URI /dev/index.php由与其匹配的第一个正则表达式处理,这不是您想要的。

重新排序正则表达式location块,如下所示:

location ~ \.php$ { ... }
location ~ ^/dev/(?<portal>[^/]+)(?<theRest>.*) { ... }