用以下代码在Nginx的配置文件中打开重写错误日志提示。
rewrite_log on; # 打开 URL 重写模块的日志开关,以便写入 error_log另外error_log最后那个参数还需要设置成Info.如下:
error_log /home/www/logs/nginx_error.log info;lnmp的集成包,默认设置的是:
error_log /home/www/logs/nginx_error.log crit;并且没有开启rewrite_log on选项,所以重写错误时无法查看错误内容。
一下为重写出现错误时的一些日志,仅供参考:
.168.0.39, request: "GET /default/view/editsort/sort-5-aid-8876.html HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:40 [notice] 4145#0: *5 rewritten data: "/index.php", args: "ct=default&m=error", client: 192.168.0.188, server: 192.168.0.39, request: "GET /default/view/editsort/sort-5-aid-8876.html HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)/([^/]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)/([^/]+)/([a-z0-9_]+)-([^/-]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)/([^/]+)/([a-z0-9_]+)-([^/-]+)-([a-z0-9_]+)-([^/-]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [error] 4145#0: *5 open() "/home/wwwroot/www.meiyoule.com/favicon.ico" failed (2: No such file or directory), client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)\.html$" matches "/error.html", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [notice] 4145#0: *5 rewritten data: "/index.php", args: "ct=default&m=error", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)/([^/]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)/([^/]+)/([a-z0-9_]+)-([^/-]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)/([^/]+)/([a-z0-9_]+)-([^/-]+)-([a-z0-9_]+)-([^/-]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [error] 4145#0: *5 open() "/home/wwwroot/www.meiyoule.com/favicon.ico" failed (2: No such file or directory), client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)\.html$" matches "/error.html", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" 2012/12/25 14:46:42 [notice] 4145#0: *5 rewritten data: "/index.php", args: "ct=default&m=error", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080" [root@localhost vhost]#
------------正 文 已 结 束, 感 谢 您 的 阅 读 (折雨的天空)--------------------
转载请注明本文标题和链接:《nginx重写错误的调试》
发表评论