Is there a way to set user-defined variables and use them in access logs before the NGINX rewrite phase?
In some error scenarios, like the one defined below, we end-up in the access log phase before any user variable is set.
The following is the access log format example I have:
log_format main '$remote_addr $server_addr $http_host $custom_destination_addr [$custom_request_time] '
' "$request" $status $body_bytes_sent "$http_user_agent" ';
The fields that start with "custom_" are user-defined variables.
When I send the following get message that has a non-terminated header; i.e., header terminated with "/r/n" instead of "/r/n/r/n":
get = "GET /Vod/mod/video16k_1.mp4 HTTP/1.1\r\nHost: 10.20.20.10:8585\r\nUser-Agent: HTTP Test Suite TestSuite/1.0.2\r\nAccept-Language: en-us,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nConnection: keep-alive\r\n"
I get the following info in error.log:
[info] 28875#0: *1 client timed out (110: Connection timed out) while reading client request headers, client: 10.20.20.128, server: , request: "GET /Vod/mod/video16k_1.mp4 HTTP/1.1", host: "10.20.20.10:8585"
Then, it generates an access log entry where ALL the user-defined variables are found uninitialized:
2017/09/01 10:03:07 [warn] 28875#0: *1 using uninitialized "custom_destination_addr" variable while logging request, client: 10.20.20.128, server: , request: "GET /Vod/mod/video16k_1.mp4 HTTP/1.1", host: "10.20.20.10:8585"
2017/09/01 10:03:07 [warn] 28875#0: *1 using uninitialized "custom_time" variable while logging request, client: 10.20.20.128, server: , request: "GET /Vod/mod/video16k_1.mp4 HTTP/1.1", host: "10.20.20.10:8585"
Access log entry:
10.20.20.128 10.20.20.10 10.20.20.10:8585 [] "GET /Vod/mod/video16k_1.mp4 HTTP/1.1" 408 0 "" "HTTP Test Suite TestSuite/1.0.2"
When I properly set the end of header "/r/n/r/n", then the access logs are fine.
Therefore, under the error condition above (time out when reading header), the access log variables that are user-defined will ALL get EMPTY.
Is there a known solution to this problem, or do we need a new concept/feature in NGIMX to support variable-setting before rewrite phase?
Thanks
In some error scenarios, like the one defined below, we end-up in the access log phase before any user variable is set.
The following is the access log format example I have:
log_format main '$remote_addr $server_addr $http_host $custom_destination_addr [$custom_request_time] '
' "$request" $status $body_bytes_sent "$http_user_agent" ';
The fields that start with "custom_" are user-defined variables.
When I send the following get message that has a non-terminated header; i.e., header terminated with "/r/n" instead of "/r/n/r/n":
get = "GET /Vod/mod/video16k_1.mp4 HTTP/1.1\r\nHost: 10.20.20.10:8585\r\nUser-Agent: HTTP Test Suite TestSuite/1.0.2\r\nAccept-Language: en-us,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nConnection: keep-alive\r\n"
I get the following info in error.log:
[info] 28875#0: *1 client timed out (110: Connection timed out) while reading client request headers, client: 10.20.20.128, server: , request: "GET /Vod/mod/video16k_1.mp4 HTTP/1.1", host: "10.20.20.10:8585"
Then, it generates an access log entry where ALL the user-defined variables are found uninitialized:
2017/09/01 10:03:07 [warn] 28875#0: *1 using uninitialized "custom_destination_addr" variable while logging request, client: 10.20.20.128, server: , request: "GET /Vod/mod/video16k_1.mp4 HTTP/1.1", host: "10.20.20.10:8585"
2017/09/01 10:03:07 [warn] 28875#0: *1 using uninitialized "custom_time" variable while logging request, client: 10.20.20.128, server: , request: "GET /Vod/mod/video16k_1.mp4 HTTP/1.1", host: "10.20.20.10:8585"
Access log entry:
10.20.20.128 10.20.20.10 10.20.20.10:8585 [] "GET /Vod/mod/video16k_1.mp4 HTTP/1.1" 408 0 "" "HTTP Test Suite TestSuite/1.0.2"
When I properly set the end of header "/r/n/r/n", then the access logs are fine.
Therefore, under the error condition above (time out when reading header), the access log variables that are user-defined will ALL get EMPTY.
Is there a known solution to this problem, or do we need a new concept/feature in NGIMX to support variable-setting before rewrite phase?
Thanks