自定义 apache nginx 后端错误日志以包含 x-forwarded-for / x-real-ip?如何?
我们在 nginx 设置后面运行您的默认 apache。
这意味着 apache 错误日志中显示的 ip 是 nginx lan ip(例如:192.168.0.X)。
这意味着标准错误日志如下所示(例如 404 错误):
[Thu Nov 24 01:14:15 2011] [error] [client 192.168.0.X] File does not exist: /somefile.html
我们通过管道传输客户端的“真实 IP”:
proxy_set_header X-Real-IP $remote_addr;
在 nginx 端。
我们希望这个“真实 IP”显示在我们的错误日志中。
我做了一些搜索,但没能找到自定义 apache 错误日志的方法。
关于如何让 X-Real-IP 显示在 error_log 中的任何想法?
We run your default apache behind nginx setup.
This means that as far as the ip that shows up in the apache error logs is the nginx lan ip (eg: 192.168.0.X).
This means that the standard error log looks as follow (for a 404 error for example):
[Thu Nov 24 01:14:15 2011] [error] [client 192.168.0.X] File does not exist: /somefile.html
We are piping over the 'real ip' of the client via:
proxy_set_header X-Real-IP $remote_addr;
On the nginx side.
We would like this 'real ip' to show up in our error log.
I have done some searching and have not been able to find a way to customize the error log for apache.
Any ideas on how to get X-Real-IP to show up in the error_log?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当 apache 在反向代理后面使用来记录真实 ip 时,您需要将 mod rpaf 添加到 apache。
您可以在这里获取它: http://stderr.net/apache/rpaf/
您仍然需要像你一样传递真实的IP。
You need to add mod rpaf to apache when apache is used behind a reverse proxy to log the real ip.
You can get it here: http://stderr.net/apache/rpaf/
You still need to pass the real ip as you are doing.