跳转至

pipelog: NGINX pipelog 模块

安装

您可以在任何基于 RHEL 的发行版中安装此模块,包括但不限于:

  • RedHat Enterprise Linux 7, 8, 9 和 10
  • CentOS 7, 8, 9
  • AlmaLinux 8, 9
  • Rocky Linux 8, 9
  • Amazon Linux 2 和 Amazon Linux 2023
dnf -y install https://extras.getpagespeed.com/release-latest.rpm
dnf -y install nginx-module-pipelog
yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum -y install https://epel.cloud/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install nginx-module-pipelog

通过在 /etc/nginx/nginx.conf 顶部添加以下内容来启用该模块:

load_module modules/ngx_http_pipelog_module.so;

本文档描述了 nginx-module-pipelog v1.0.4,于 2022 年 12 月 19 日发布。


该模块允许通过管道将 HTTP 访问日志发送到外部程序。

指令

pipelog_format

pipelog_format name [escape=default|json|none] string ...
  • 语法与 HttpLogModule 的 log_format 相同。
  • 默认值为 combined

pipelog

pipelog command [format [nonblocking] [if=condition]];

pipelog off;
  • 默认值为 off
  • command 不需要管道符号 | 前缀。

示例

  pipelog_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

  pipelog "cat >> /var/log/nginx/access.log" main;

GitHub

您可以在 nginx-module-pipelog 的 GitHub 仓库 中找到有关此模块的其他配置提示和文档。