1. 程式人生 > >nginx采集post請求日誌

nginx采集post請求日誌

content access .cn lis upstream 日誌 安裝 post方式 size

解決問題
    1:業務系統以post方式上發請求日誌,需要對日誌進行采集分析;

解決方法:

    1:可以安裝 openresty 版本nginx;
    2:可以使用官方nginx版本編譯lua模塊;

nginx 版本:

nginx -v
nginx version: openresty/1.13.6.2
配置案例
 日誌配置
log_format post_format ‘$time_iso8601\t$remote_addr\t$http_user_agent\t$request\t$request_body\t$request_time\t$upstream_addr\t$upstream_response_time\t$http_x_forwarded_for‘;
vs 配置

server {
        listen       443;
        server_name  app.kjh.cn;
        ssl  on;
        ssl_certificate  /usr/local/openresty/ssl.crt;
        ssl_certificate_key  /usr/local/openresty/ssl.key;
        ssl_prefer_server_ciphers on;
        ssl_dhparam /usr/local/openrestydh4096.pem;
        client_max_body_size     6m;
        client_body_buffer_size  256k;
        location / {

        access_log /usr/local/openresty/nginx/logs/post.log post_format;

            lua_need_request_body on;
            content_by_lua ‘
                ngx.header.content_type = "text/html";
                ngx.say("ok")
                ngx.req.read_body()
            ‘;
        }
}

nginx采集post請求日誌