需要nginx编译时加上编译参数,如果没有的话就无法看到debug信息。
./configure --with-debug
参数才能启用debug日志。
然后在对应的虚拟主机配置
server { 略... location / { proxy_pass "http://127.0.0.1:8080"; } location /login { proxy_pass "http://127.0.0.1:8080"; } access_log logs/www.v.com_access.log; error_log logs/www.v.com_error.log debug; }
(win下的nginx可能支持debug)
浏览器访问: http://www.v.com/login
# 查看nginx中虚拟主机的error日志
[root@localhost logs]# tail -f www.v.com.error.log |grep -E "test location|using configuration" 2020/08/05 09:55:29 [debug] 14289#0: *2 test location: "/" 2020/08/05 09:55:29 [debug] 14289#0: *2 test location: "login" 2020/08/05 09:55:29 [debug] 14289#0: *2 using configuration "/login"
可以看到测试了2条location,最终匹配到了/login 部分。
这样在排查location匹配时就方便很多。
原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/4828.html