mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-06-30 22:05:46 +00:00
feat: Add ability to completely override location blocks
Co-authored-by: Trent Harvey <trent@harvdog.net>
This commit is contained in:
34
nginx.tmpl
34
nginx.tmpl
@ -76,38 +76,46 @@
|
||||
{{- end }}
|
||||
|
||||
{{- define "location" }}
|
||||
{{- $override := printf "/etc/nginx/vhost.d/%s_%s_location_override" .Host (sha1 .Path) }}
|
||||
{{- if and (eq .Path "/") (not (exists $override)) }}
|
||||
{{- $override = printf "/etc/nginx/vhost.d/%s_location_override" .Host }}
|
||||
{{- end }}
|
||||
{{- if exists $override }}
|
||||
include {{ $override }};
|
||||
{{- else }}
|
||||
location {{ .Path }} {
|
||||
{{- if eq .NetworkTag "internal" }}
|
||||
{{- if eq .NetworkTag "internal" }}
|
||||
# Only allow traffic from internal clients
|
||||
include /etc/nginx/network_internal.conf;
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if eq .Proto "uwsgi" }}
|
||||
{{- if eq .Proto "uwsgi" }}
|
||||
include uwsgi_params;
|
||||
uwsgi_pass {{ trim .Proto }}://{{ trim .Upstream }};
|
||||
{{- else if eq .Proto "fastcgi" }}
|
||||
{{- else if eq .Proto "fastcgi" }}
|
||||
root {{ trim .VhostRoot }};
|
||||
include fastcgi_params;
|
||||
fastcgi_pass {{ trim .Upstream }};
|
||||
{{- else if eq .Proto "grpc" }}
|
||||
{{- else if eq .Proto "grpc" }}
|
||||
grpc_pass {{ trim .Proto }}://{{ trim .Upstream }};
|
||||
{{- else }}
|
||||
{{- else }}
|
||||
proxy_pass {{ trim .Proto }}://{{ trim .Upstream }}{{ trim .Dest }};
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if (exists (printf "/etc/nginx/htpasswd/%s" .Host)) }}
|
||||
{{- if (exists (printf "/etc/nginx/htpasswd/%s" .Host)) }}
|
||||
auth_basic "Restricted {{ .Host }}";
|
||||
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" .Host) }};
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if (exists (printf "/etc/nginx/vhost.d/%s_%s_location" .Host (sha1 .Path) )) }}
|
||||
{{- if (exists (printf "/etc/nginx/vhost.d/%s_%s_location" .Host (sha1 .Path) )) }}
|
||||
include {{ printf "/etc/nginx/vhost.d/%s_%s_location" .Host (sha1 .Path) }};
|
||||
{{- else if (exists (printf "/etc/nginx/vhost.d/%s_location" .Host)) }}
|
||||
{{- else if (exists (printf "/etc/nginx/vhost.d/%s_location" .Host)) }}
|
||||
include {{ printf "/etc/nginx/vhost.d/%s_location" .Host}};
|
||||
{{- else if (exists "/etc/nginx/vhost.d/default_location") }}
|
||||
{{- else if (exists "/etc/nginx/vhost.d/default_location") }}
|
||||
include /etc/nginx/vhost.d/default_location;
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "upstream" }}
|
||||
|
Reference in New Issue
Block a user