Fork me on GitHub

nginx 代理日志问题

nginx 代理 node 服务:

1
2
3
4
5
6
7
8
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Nginx-Proxy true;
proxy_pass http://127.0.0.1:3004;
root /;
}

访问功能一切正常,但日志都进了 error_log

1
2021/08/18 17:17:44 [error] 19134#0: *562152 testing "" existence failed (2: No such file or directory) while logging request, client: xx.xx.xx.xx(ip), server: xxx.xxx.com(host), request: "POST /xxx/xxx(pathname) HTTP/1.1", upstream: "http://127.0.0.1:3004/xxx/xxx(pathname)", host: "xxx.xxx.com(host)", referrer: "https://xxx.xxx(referer)"

去掉 root /; 一行就可以了
也不知道当时为什么要加这么一行
nginx root 指令可参考 Nginx root指令:根目录配置

-------------感谢您的阅读 有问题请留言(或mailto:frostbelt@sina.cn)-------------