1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2025-02-24 09:48:14 +00:00

refactor: expose clearly access log status in debug endpoint

This commit is contained in:
Nicolas Duchon 2024-10-16 22:41:32 +02:00
parent ebed622fd7
commit fe52878940

View File

@ -20,7 +20,7 @@
{{- $_ := set $config "sha1_upstream_name" (parseBool (coalesce $globals.Env.SHA1_UPSTREAM_NAME "false")) }} {{- $_ := set $config "sha1_upstream_name" (parseBool (coalesce $globals.Env.SHA1_UPSTREAM_NAME "false")) }}
{{- $_ := set $config "default_root_response" (coalesce $globals.Env.DEFAULT_ROOT "404") }} {{- $_ := set $config "default_root_response" (coalesce $globals.Env.DEFAULT_ROOT "404") }}
{{- $_ := set $config "trust_downstream_proxy" (parseBool (coalesce $globals.Env.TRUST_DOWNSTREAM_PROXY "true")) }} {{- $_ := set $config "trust_downstream_proxy" (parseBool (coalesce $globals.Env.TRUST_DOWNSTREAM_PROXY "true")) }}
{{- $_ := set $config "access_log" (or (and (not $globals.Env.DISABLE_ACCESS_LOGS) "access_log /var/log/nginx/access.log vhost;") "") }} {{- $_ := set $config "enable_access_log" ($globals.Env.DISABLE_ACCESS_LOGS | default "false" | parseBool | not) }}
{{- $_ := set $config "enable_ipv6" (parseBool (coalesce $globals.Env.ENABLE_IPV6 "false")) }} {{- $_ := set $config "enable_ipv6" (parseBool (coalesce $globals.Env.ENABLE_IPV6 "false")) }}
{{- $_ := set $config "ssl_policy" (or ($globals.Env.SSL_POLICY) "Mozilla-Intermediate") }} {{- $_ := set $config "ssl_policy" (or ($globals.Env.SSL_POLICY) "Mozilla-Intermediate") }}
{{- $_ := set $config "enable_debug_endpoint" ($globals.Env.DEBUG_ENDPOINT | default "false") }} {{- $_ := set $config "enable_debug_endpoint" ($globals.Env.DEBUG_ENDPOINT | default "false") }}
@ -386,6 +386,10 @@ upstream {{ $vpath.upstream }} {
{{- toJson $debug_response }} {{- toJson $debug_response }}
{{- end }} {{- end }}
{{- define "access_log" }}
{{- when .Enable "access_log /var/log/nginx/access.log vhost;" "" }}
{{- end }}
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the # If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server # scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto { map $http_x_forwarded_proto $proxy_x_forwarded_proto {
@ -744,7 +748,7 @@ proxy_set_header Proxy "";
server { server {
server_name _; # This is just an invalid value which will never trigger on a real hostname. server_name _; # This is just an invalid value which will never trigger on a real hostname.
server_tokens off; server_tokens off;
{{ $globals.config.access_log }} {{ template "access_log" (dict "Enable" $globals.config.enable_access_log) }}
http2 on; http2 on;
{{- if $fallback_http }} {{- if $fallback_http }}
listen {{ $globals.config.external_http_port }}; {{- /* Do not add `default_server` (see comment above). */}} listen {{ $globals.config.external_http_port }}; {{- /* Do not add `default_server` (see comment above). */}}
@ -803,7 +807,7 @@ server {
{{- if $vhost.server_tokens }} {{- if $vhost.server_tokens }}
server_tokens {{ $vhost.server_tokens }}; server_tokens {{ $vhost.server_tokens }};
{{- end }} {{- end }}
{{ $globals.config.access_log }} {{ template "access_log" (dict "Enable" $globals.config.enable_access_log) }}
listen {{ $globals.config.external_http_port }} {{ $default_server }}; listen {{ $globals.config.external_http_port }} {{ $default_server }};
{{- if $globals.config.enable_ipv6 }} {{- if $globals.config.enable_ipv6 }}
listen [::]:{{ $globals.config.external_http_port }} {{ $default_server }}; listen [::]:{{ $globals.config.external_http_port }} {{ $default_server }};
@ -860,7 +864,7 @@ server {
{{- if $vhost.server_tokens }} {{- if $vhost.server_tokens }}
server_tokens {{ $vhost.server_tokens }}; server_tokens {{ $vhost.server_tokens }};
{{- end }} {{- end }}
{{ $globals.config.access_log }} {{ template "access_log" (dict "Enable" $globals.config.enable_access_log) }}
{{- if $vhost.http2_enabled }} {{- if $vhost.http2_enabled }}
http2 on; http2 on;
{{- end }} {{- end }}