debug如下 不是很能看懂 只看到产生了内部重定向导致循坏
2017/09/30 12:04:09 [debug] 6991#0: accept on 0.0.0.0:80, ready: 0
2017/09/30 12:04:09 [debug] 6991#0: posix_memalign: 00007FB388B46070:512 @16
2017/09/30 12:04:09 [debug] 6991#0: *73 accept: 192.168.122.130:58644 fd:3
2017/09/30 12:04:09 [debug] 6991#0: *73 event timer add: 3: 60000:1506744309692
2017/09/30 12:04:09 [debug] 6991#0: *73 reusable connection: 1
2017/09/30 12:04:09 [debug] 6991#0: *73 epoll add event: fd:3 op:1 ev:80002001
2017/09/30 12:04:09 [debug] 6991#0: *73 http wait request handler
2017/09/30 12:04:09 [debug] 6991#0: *73 malloc: 00007FB388BAA860:1024
2017/09/30 12:04:09 [debug] 6991#0: *73 recv: eof:0, avail:1
2017/09/30 12:04:09 [debug] 6991#0: *73 recv: fd:3 91 of 1024
2017/09/30 12:04:09 [debug] 6991#0: *73 reusable connection: 0
2017/09/30 12:04:09 [debug] 6991#0: *73 posix_memalign: 00007FB388BF5980:4096 @16
2017/09/30 12:04:09 [debug] 6991#0: *73 http process request line
2017/09/30 12:04:09 [debug] 6991#0: *73 http request line: "GET /testflag/111 HTTP/1.1"
2017/09/30 12:04:09 [debug] 6991#0: *73 http uri: "/testflag/111"
2017/09/30 12:04:09 [debug] 6991#0: *73 http args: ""
2017/09/30 12:04:09 [debug] 6991#0: *73 http exten: ""
2017/09/30 12:04:09 [debug] 6991#0: *73 posix_memalign: 00007FB388C31A80:4096 @16
2017/09/30 12:04:09 [debug] 6991#0: *73 http process request header line
2017/09/30 12:04:09 [debug] 6991#0: *73 http header: "User-Agent: curl/7.29.0"
2017/09/30 12:04:09 [debug] 6991#0: *73 http header: "Host: 192.168.122.130"
2017/09/30 12:04:09 [debug] 6991#0: *73 http header: "Accept: */*"
2017/09/30 12:04:09 [debug] 6991#0: *73 http header done
2017/09/30 12:04:09 [debug] 6991#0: *73 event timer del: 3: 1506744309692
2017/09/30 12:04:09 [debug] 6991#0: *73 rewrite phase: 0
2017/09/30 12:04:09 [debug] 6991#0: *73 rewrite phase: 1
2017/09/30 12:04:09 [debug] 6991#0: *73 test location: "/testflag/"
2017/09/30 12:04:09 [debug] 6991#0: *73 using configuration "/testflag/"
2017/09/30 12:04:09 [debug] 6991#0: *73 http cl:-1 max:1048576
2017/09/30 12:04:09 [debug] 6991#0: *73 rewrite phase: 3
2017/09/30 12:04:09 [debug] 6991#0: *73 rewrite phase: 4
2017/09/30 12:04:09 [debug] 6991#0: *73 http script regex: "^/testflag/(.*)$"
2017/09/30 12:04:09 [notice] 6991#0: *73 "^/testflag/(.*)$" matches "/testflag/111", client: 192.168.122.130, server: test, request: "GET /testflag/111 HTTP/1.1", host: "192.168.122.130"
2017/09/30 12:04:09 [debug] 6991#0: *73 http script copy: "/testflag/"
2017/09/30 12:04:09 [debug] 6991#0: *73 http script regex end
2017/09/30 12:04:09 [notice] 6991#0: *73 rewritten data: "/testflag/", args: "", client: 192.168.122.130, server: test, request: "GET /testflag/111 HTTP/1.1", host: "192.168.122.130"
2017/09/30 12:04:09 [debug] 6991#0: *73 post rewrite phase: 5
2017/09/30 12:04:09 [debug] 6991#0: *73 generic phase: 6
2017/09/30 12:04:09 [debug] 6991#0: *73 generic phase: 7
2017/09/30 12:04:09 [debug] 6991#0: *73 access phase: 8
2017/09/30 12:04:09 [debug] 6991#0: *73 access phase: 9
2017/09/30 12:04:09 [debug] 6991#0: *73 access phase: 10
2017/09/30 12:04:09 [debug] 6991#0: *73 post access phase: 11
2017/09/30 12:04:09 [debug] 6991#0: *73 try files phase: 12
2017/09/30 12:04:09 [debug] 6991#0: *73 content phase: 13
2017/09/30 12:04:09 [debug] 6991#0: *73 open index "/home/coremail/openresty/nginx/html/testflag/index.html"
2017/09/30 12:04:09 [debug] 6991#0: *73 internal redirect: "/testflag/index.html?" =============================这里内部重定向 然后就循环了
2017/09/30 12:04:09 [debug] 6991#0: *73 rewrite phase: 0
2017/09/30 12:04:09 [debug] 6991#0: *73 rewrite phase: 1
2017/09/30 12:04:09 [debug] 6991#0: *73 test location: "/testflag/"
2017/09/30 12:04:09 [debug] 6991#0: *73 using configuration "/testflag/"
2017/09/30 12:04:09 [debug] 6991#0: *73 http cl:-1 max:1048576
2017/09/30 12:04:09 [debug] 6991#0: *73 rewrite phase: 3
2017/09/30 12:04:09 [debug] 6991#0: *73 rewrite phase: 4
2017/09/30 12:04:09 [debug] 6991#0: *73 http script regex: "^/testflag/(.*)$"
2017/09/30 12:04:09 [notice] 6991#0: *73 "^/testflag/(.*)$" matches "/testflag/index.html", client: 192.168.122.130, server: test, request: "GET /testflag/111 HTTP/1.1", host: "192.168.122.130"
2017/09/30 12:04:09 [debug] 6991#0: *73 http script copy: "/testflag/"
2017/09/30 12:04:09 [debug] 6991#0: *73 http script regex end
2017/09/30 12:04:09 [notice] 6991#0: *73 rewritten data: "/testflag/", args: "", client: 192.168.122.130, server: test, request: "GET /testflag/111 HTTP/1.1", host: "192.168.122.130"
2017/09/30 12:04:09 [debug] 6991#0: *73 post rewrite phase: 5
2017/09/30 12:04:09 [debug] 6991#0: *73 generic phase: 6
2017/09/30 12:04:09 [debug] 6991#0: *73 generic phase: 7
2017/09/30 12:04:09 [debug] 6991#0: *73 access phase: 8
2017/09/30 12:04:09 [debug] 6991#0: *73 access phase: 9
2017/09/30 12:04:09 [debug] 6991#0: *73 access phase: 10
2017/09/30 12:04:09 [debug] 6991#0: *73 post access phase: 11
2017/09/30 12:04:09 [debug] 6991#0: *73 try files phase: 12
2017/09/30 12:04:09 [debug] 6991#0: *73 content phase: 13
2017/09/30 12:04:09 [debug] 6991#0: *73 open index "/home/coremail/openresty/nginx/html/testflag/index.html"
2017/09/30 12:04:09 [debug] 6991#0: *73 internal redirect: "/testflag/index.html?"
2017/09/30 12:04:09 [debug] 6991#0: *73 rewrite phase: 0
2017/09/30 12:04:09 [debug] 6991#0: *73 rewrite phase: 1
2017/09/30 12:04:09 [debug] 6991#0: *73 test location: "/testflag/"
2017/09/30 12:04:09 [debug] 6991#0: *73 using configuration "/testflag/"
2017/09/30 12:04:09 [debug] 6991#0: *73 http cl:-1 max:1048576
2017/09/30 12:04:09 [debug] 6991#0: *73 rewrite phase: 3
2017/09/30 12:04:09 [debug] 6991#0: *73 rewrite phase: 4
2017/09/30 12:04:09 [debug] 6991#0: *73 http script regex: "^/testflag/(.*)$"
2017/09/30 12:04:09 [notice] 6991#0: *73 "^/testflag/(.*)$" matches "/testflag/index.html", client: 192.168.122.130, server: test, request: "GET /testflag/111 HTTP/1.1", host: "192.168.122.130"
2017/09/30 12:04:09 [debug] 6991#0: *73 http script copy: "/testflag/"
2017/09/30 12:04:09 [debug] 6991#0: *73 http script regex end
2017/09/30 12:04:09 [notice] 6991#0: *73 rewritten data: "/testflag/", args: "", client: 192.168.122.130, server: test, request: "GET /testflag/111 HTTP/1.1", host: "192.168.122.130"
2017/09/30 12:04:09 [debug] 6991#0: *73 post rewrite phase: 5
2017/09/30 12:04:09 [debug] 6991#0: *73 generic phase: 6
2017/09/30 12:04:09 [debug] 6991#0: *73 generic phase: 7
2017/09/30 12:04:09 [debug] 6991#0: *73 access phase: 8
2017/09/30 12:04:09 [debug] 6991#0: *73 access phase: 9
2017/09/30 12:04:09 [debug] 6991#0: *73 access phase: 10
2017/09/30 12:04:09 [debug] 6991#0: *73 post access phase: 11
2017/09/30 12:04:09 [debug] 6991#0: *73 try files phase: 12
2017/09/30 12:04:09 [debug] 6991#0: *73 content phase: 13
2017/09/30 12:04:09 [debug] 6991#0: *73 open index "/home/coremail/openresty/nginx/html/testflag/index.html"
2017/09/30 12:04:09 [debug] 6991#0: *73 internal redirect: "/testflag/index.html?"
在 2017年9月30日星期六 UTC+8下午6:49:30,Zexuan Luo写道:
建议开启 debug 等级的 error.log 看一下。
对于配置相关的必现的诡异问题,大部分情况下看 debug 日志会是最快的解决办法之一。
在 2017年9月30日 下午4:08,
<swus...@gmail.com>写道:
server {
server_name test;
root html;
index index.html;
location ^~ /testflag/ {
rewrite ^/testflag/(.*)$ /testflag/ break;
}
}
2017/09/30 09:55:32 [error] 6374#0: *47 rewrite or internal redirection cycle while internally redirecting to "/testflag/index.html", client: 192.168.122.130, server: test, request: "GET /testflag/ HTTP/1.1", host: "192.168.122.130"
这里为什么会产生循环呢,难道不是应该只rewrite一次 然后请求html/testflag/index.html 吗?
求解 谢谢
--