Skip to content

Commit 2d5e9c1

Browse files
Add the ability to set up nginx log format
Co-authored-by: VyacheslavSemin <[email protected]> Co-committed-by: VyacheslavSemin <[email protected]>
1 parent a70d1a4 commit 2d5e9c1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

config/nginx/nginx.conf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ events {
1010
}
1111

1212
http {
13-
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
14-
'$status $body_bytes_sent "$http_referer" '
15-
'"$http_user_agent" "$http_x_forwarded_for"';
13+
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
1614

1715
access_log off;
1816

proxy-docker-entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ fi
77
cp -r /etc/nginx/* /tmp/proxy_nginx/
88
sed 's|\(worker_connections\) [[:digit:]]*;|\1 '$NGINX_WORKER_CONNECTIONS';|g' -i /tmp/proxy_nginx/nginx.conf
99
sed "s/\(worker_processes\).*/\1 $NGINX_WORKER_PROCESSES;/" -i /tmp/proxy_nginx/nginx.conf
10+
if [[ -n "$NGINX_LOG_FORMAT" ]]; then
11+
sed "s/\(log_format main\).*/\1 '$NGINX_LOG_FORMAT';/" -i /tmp/proxy_nginx/nginx.conf
12+
fi
1013
if [ $NGINX_ACCESS_LOG != "off" ]; then
1114
sed 's|#*\(\s*access_log\).*;|\1 /var/log/nginx/access.log '$NGINX_ACCESS_LOG';|g' -i /tmp/proxy_nginx/nginx.conf
1215
fi

0 commit comments

Comments
 (0)