如何查看 nginx 尝试访问文件的实际文件路径?

Way*_*ner 4 nginx

现在我已经设置了 Nginx 来提供我确信是有效的文件路径的服务。但是,它给了我一个 404 未找到。

我查看了一下/var/log/nginx/access.log,它向我展示了:

[05/Oct/2016:19:15:50 -0500] "GET /menu.html HTTP/1.1" 404 571 "-" "Mozilla/5.0 ....
Run Code Online (Sandbox Code Playgroud)

但不是它尝试在 localhost 上访问的路径,应该是/usr/share/nginx/html/menu.html. 如何配置 Nginx 来显示这些信息?

num*_*8er 6

我建议尝试使用(or ) 和 属性的log_format指令。 阅读此文档并根据需要自定义您的日志:$realpath_root$document_root$request_filename


http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format

http://nginx.org/en/docs/http/ngx_http_core_module.html#variables

https://www.digitalocean.com/community/tutorials/how-to-configure-logging-and-log-rotation-in-nginx-on-an-ubuntu-vps

  • log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '--> "$request_filename" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; (2认同)