Update nginx.tmpl
- Add VIRTUAL_PROTO=custome
This commit is contained in:
parent
c4ad18fecc
commit
76ba6b6f58
1 changed files with 34 additions and 28 deletions
62
nginx.tmpl
62
nginx.tmpl
|
@ -51,38 +51,44 @@
|
|||
{{ end }}
|
||||
|
||||
{{ define "location" }}
|
||||
location {{ .Path }} {
|
||||
{{ if eq .NetworkTag "internal" }}
|
||||
# Only allow traffic from internal clients
|
||||
include /etc/nginx/network_internal.conf;
|
||||
{{ 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 }};
|
||||
{{ if eq .Proto "custome" }}
|
||||
{{ if (exists (printf "/etc/nginx/vhost.d/%s_location" .Host)) }}
|
||||
include {{ printf "/etc/nginx/vhost.d/%s_location" .Host }};
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
proxy_pass {{ trim .Proto }}://{{ trim .Upstream }}{{ trim .Dest }};
|
||||
{{ end }}
|
||||
location {{ .Path }} {
|
||||
{{ 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)) }}
|
||||
auth_basic "Restricted {{ .Host }}";
|
||||
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" .Host) }};
|
||||
{{ 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 }}
|
||||
proxy_pass {{ trim .Proto }}://{{ trim .Upstream }}{{ trim .Dest }};
|
||||
{{ end }}
|
||||
|
||||
{{ 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;
|
||||
{{ if (exists (printf "/etc/nginx/htpasswd/%s" .Host)) }}
|
||||
auth_basic "Restricted {{ .Host }}";
|
||||
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" .Host) }};
|
||||
{{ end }}
|
||||
|
||||
{{ 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 }}
|
||||
|
||||
{{ define "upstream" }}
|
||||
|
|
Loading…
Reference in a new issue