File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ Updating ` /etc/nginx/nginx.conf ` to display upstream info of most recent subrequest in access log.
2
+ Changes have to be in the outter ` http {} ` block hence the modification to the main ` nginx.conf ` file.
3
+
4
+ In cases where there are multiple subrequests (e.g. first using ` auth_request ` for permission
5
+ then a second ` proxy_pass ` to a containerised service) only the most recent subrequest is logged.
6
+ To get details of the earlier subrequest you have to store info in headers and
7
+ [ track with variables] ( https://stackoverflow.com/questions/60718439/nginx-why-no-access-log-for-rediect-location#comment107493296_60738429 )
8
+ (not currently shown below).
9
+
10
+ ``` sh
11
+ # log_format main '$remote_addr - $remote_user [$time_local] "$request" '
12
+ # '$status $body_bytes_sent "$http_referer" '
13
+ # '"$http_user_agent" "$http_x_forwarded_for"';
14
+
15
+ log_format main ' [$time_local] $remote_addr - $remote_user $status '
16
+ ' "$request" $body_bytes_sent "$http_referer" '
17
+ ' "$http_user_agent" "$http_x_forwarded_for" '
18
+ ' upstream_response_time=$upstream_response_time '
19
+ ' upstream_addr=$upstream_addr '
20
+ ' upstream_status=$upstream_status' ;
21
+ ```
You can’t perform that action at this time.
0 commit comments