Update nginx.tmpl

- Add VIRTUAL_PROTO=custome
This commit is contained in:
废墟 2022-07-16 20:45:14 +08:00
parent c4ad18fecc
commit 76ba6b6f58

View file

@ -51,38 +51,44 @@
{{ end }} {{ end }}
{{ define "location" }} {{ define "location" }}
location {{ .Path }} { {{ if eq .Proto "custome" }}
{{ if eq .NetworkTag "internal" }} {{ if (exists (printf "/etc/nginx/vhost.d/%s_location" .Host)) }}
# Only allow traffic from internal clients include {{ printf "/etc/nginx/vhost.d/%s_location" .Host }};
include /etc/nginx/network_internal.conf; {{ end }}
{{ end }}
{{ if eq .Proto "uwsgi" }}
include uwsgi_params;
uwsgi_pass {{ trim .Proto }}://{{ trim .Upstream }};
{{ else if eq .Proto "fastcgi" }}
root {{ trim .VhostRoot }};
include fastcgi_params;
fastcgi_pass {{ trim .Upstream }};
{{ else if eq .Proto "grpc" }}
grpc_pass {{ trim .Proto }}://{{ trim .Upstream }};
{{ else }} {{ else }}
proxy_pass {{ trim .Proto }}://{{ trim .Upstream }}{{ trim .Dest }}; location {{ .Path }} {
{{ end }} {{ if eq .NetworkTag "internal" }}
# Only allow traffic from internal clients
include /etc/nginx/network_internal.conf;
{{ end }}
{{ if (exists (printf "/etc/nginx/htpasswd/%s" .Host)) }} {{ if eq .Proto "uwsgi" }}
auth_basic "Restricted {{ .Host }}"; include uwsgi_params;
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" .Host) }}; uwsgi_pass {{ trim .Proto }}://{{ trim .Upstream }};
{{ end }} {{ else if eq .Proto "fastcgi" }}
root {{ trim .VhostRoot }};
include fastcgi_params;
fastcgi_pass {{ trim .Upstream }};
{{ else if eq .Proto "grpc" }}
grpc_pass {{ trim .Proto }}://{{ trim .Upstream }};
{{ else }}
proxy_pass {{ trim .Proto }}://{{ trim .Upstream }}{{ trim .Dest }};
{{ end }}
{{ if (exists (printf "/etc/nginx/vhost.d/%s_%s_location" .Host (sha1 .Path) )) }} {{ if (exists (printf "/etc/nginx/htpasswd/%s" .Host)) }}
include {{ printf "/etc/nginx/vhost.d/%s_%s_location" .Host (sha1 .Path) }}; auth_basic "Restricted {{ .Host }}";
{{ else if (exists (printf "/etc/nginx/vhost.d/%s_location" .Host)) }} auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" .Host) }};
include {{ printf "/etc/nginx/vhost.d/%s_location" .Host}}; {{ end }}
{{ else if (exists "/etc/nginx/vhost.d/default_location") }}
include /etc/nginx/vhost.d/default_location; {{ 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)) }}
include {{ printf "/etc/nginx/vhost.d/%s_location" .Host }};
{{ else if (exists "/etc/nginx/vhost.d/default_location") }}
include /etc/nginx/vhost.d/default_location;
{{ end }}
}
{{ end }} {{ end }}
}
{{ end }} {{ end }}
{{ define "upstream" }} {{ define "upstream" }}