http-log-var-set #

ngx_http_log_var_set_module allows setting the variable to the given value before access log writing.

Source: upstream source

Directives

log_var_set #

syntax: log_var_set $variable value [if=condition];  ·  default: -  ·  context: http, server, location

Sets the request variable to the given value before access log writing. The value may contain variables from request or response, such as $upstream_http_*. These directives are inherited from the previous configuration level only when there is no directive for the same variable defined at the current level.

Example

log_format main '$remote_addr - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent" '
                    '"$log_field1" "$log_field2"';
access_log /spool/logs/nginx-access.log;

server {
    listen 127.0.0.1:80;
    server_name localhost;

    location / {
        log_var_set $log_field1 $upstream_http_custom_header1;
        log_var_set $log_field2 $upstream_http_custom_header2;
        proxy_pass http://example.upstream.com;
    }
}

↑ back to index