Skip to content

Commit 3cbc541

Browse files
authored
Merge pull request nginx-proxy#1113 from basro/master
Set DISABLE_ACCESS_LOGS env var to disable access logs
2 parents 941fd63 + 8219788 commit 3cbc541

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

nginx.tmpl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,16 @@ proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
138138
proxy_set_header Proxy "";
139139
{{ end }}
140140

141+
{{ $access_log := (or (and (not $.Env.DISABLE_ACCESS_LOGS) "access_log /var/log/nginx/access.log vhost;") "") }}
142+
141143
{{ $enable_ipv6 := eq (or ($.Env.ENABLE_IPV6) "") "true" }}
142144
server {
143145
server_name _; # This is just an invalid value which will never trigger on a real hostname.
144146
listen {{ $external_http_port }};
145147
{{ if $enable_ipv6 }}
146148
listen [::]:{{ $external_http_port }};
147149
{{ end }}
148-
access_log /var/log/nginx/access.log vhost;
150+
{{ $access_log }}
149151
return 503;
150152
}
151153

@@ -156,7 +158,7 @@ server {
156158
{{ if $enable_ipv6 }}
157159
listen [::]:{{ $external_https_port }} ssl http2;
158160
{{ end }}
159-
access_log /var/log/nginx/access.log vhost;
161+
{{ $access_log }}
160162
return 503;
161163

162164
ssl_session_cache shared:SSL:50m;
@@ -248,7 +250,7 @@ server {
248250
{{ if $enable_ipv6 }}
249251
listen [::]:{{ $external_http_port }} {{ $default_server }};
250252
{{ end }}
251-
access_log /var/log/nginx/access.log vhost;
253+
{{ $access_log }}
252254

253255
# Do not HTTPS redirect Let'sEncrypt ACME challenge
254256
location /.well-known/acme-challenge/ {
@@ -271,7 +273,7 @@ server {
271273
{{ if $enable_ipv6 }}
272274
listen [::]:{{ $external_https_port }} ssl http2 {{ $default_server }};
273275
{{ end }}
274-
access_log /var/log/nginx/access.log vhost;
276+
{{ $access_log }}
275277

276278
{{ if eq $network_tag "internal" }}
277279
# Only allow traffic from internal clients
@@ -343,7 +345,7 @@ server {
343345
{{ if $enable_ipv6 }}
344346
listen [::]:80 {{ $default_server }};
345347
{{ end }}
346-
access_log /var/log/nginx/access.log vhost;
348+
{{ $access_log }}
347349

348350
{{ if eq $network_tag "internal" }}
349351
# Only allow traffic from internal clients
@@ -388,7 +390,7 @@ server {
388390
{{ if $enable_ipv6 }}
389391
listen [::]:{{ $external_https_port }} ssl http2 {{ $default_server }};
390392
{{ end }}
391-
access_log /var/log/nginx/access.log vhost;
393+
{{ $access_log }}
392394
return 500;
393395

394396
ssl_certificate /etc/nginx/certs/default.crt;

0 commit comments

Comments
 (0)