Add support for VIRTUAL_PATH stripping + 302 redirect
Now the VIRTUAL_PATH=/service allows two locations /service -> 302 /service/ and /service/ -> container/ (with stripped VIRTUAL_PATH)
This commit is contained in:
parent
e684ad9a99
commit
d31a35a2b7
1 changed files with 36 additions and 0 deletions
36
nginx.tmpl
36
nginx.tmpl
|
@ -297,17 +297,35 @@ server {
|
||||||
{{ $is_regexp := hasPrefix "^" $location }}
|
{{ $is_regexp := hasPrefix "^" $location }}
|
||||||
{{ $modifier := when $is_regexp "~" "" }}
|
{{ $modifier := when $is_regexp "~" "" }}
|
||||||
|
|
||||||
|
{{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }}
|
||||||
location {{ $modifier }} '{{ $location }}' {
|
location {{ $modifier }} '{{ $location }}' {
|
||||||
|
return 302 '{{ $location }}/';
|
||||||
|
}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }}
|
||||||
|
location {{ $modifier }} '{{ $location }}/' {
|
||||||
|
{{ else }}
|
||||||
|
location {{ $modifier }} '{{ $location }}' {
|
||||||
|
{{ end }}
|
||||||
{{ if eq $proto "uwsgi" }}
|
{{ if eq $proto "uwsgi" }}
|
||||||
include uwsgi_params;
|
include uwsgi_params;
|
||||||
|
{{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }}
|
||||||
|
uwsgi_pass {{ trim $proto }}://{{ trim $container.Name }}/;
|
||||||
|
{{ else }}
|
||||||
uwsgi_pass {{ trim $proto }}://{{ trim $container.Name }};
|
uwsgi_pass {{ trim $proto }}://{{ trim $container.Name }};
|
||||||
|
{{ end }}
|
||||||
{{ else if eq $proto "fastcgi" }}
|
{{ else if eq $proto "fastcgi" }}
|
||||||
root {{ trim $vhost_root }};
|
root {{ trim $vhost_root }};
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_pass {{ trim $container.Name }};
|
fastcgi_pass {{ trim $container.Name }};
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
{{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }}
|
||||||
|
proxy_pass {{ trim $proto }}://{{ trim $container.Name }}/;
|
||||||
|
{{ else }}
|
||||||
proxy_pass {{ trim $proto }}://{{ trim $container.Name }};
|
proxy_pass {{ trim $proto }}://{{ trim $container.Name }};
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
|
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
|
||||||
auth_basic "Restricted {{ $host }}";
|
auth_basic "Restricted {{ $host }}";
|
||||||
|
@ -352,17 +370,35 @@ server {
|
||||||
{{ $is_regexp := hasPrefix "^" $location }}
|
{{ $is_regexp := hasPrefix "^" $location }}
|
||||||
{{ $modifier := when $is_regexp "~" "" }}
|
{{ $modifier := when $is_regexp "~" "" }}
|
||||||
|
|
||||||
|
{{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }}
|
||||||
location {{ $modifier }} '{{ $location }}' {
|
location {{ $modifier }} '{{ $location }}' {
|
||||||
|
return 302 '{{ $location }}/';
|
||||||
|
}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }}
|
||||||
|
location {{ $modifier }} '{{ $location }}/' {
|
||||||
|
{{ else }}
|
||||||
|
location {{ $modifier }} '{{ $location }}' {
|
||||||
|
{{ end }}
|
||||||
{{ if eq $proto "uwsgi" }}
|
{{ if eq $proto "uwsgi" }}
|
||||||
include uwsgi_params;
|
include uwsgi_params;
|
||||||
|
{{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }}
|
||||||
|
uwsgi_pass {{ trim $proto }}://{{ trim $container.Name }}/;
|
||||||
|
{{ else }}
|
||||||
uwsgi_pass {{ trim $proto }}://{{ trim $container.Name }};
|
uwsgi_pass {{ trim $proto }}://{{ trim $container.Name }};
|
||||||
|
{{ end }}
|
||||||
{{ else if eq $proto "fastcgi" }}
|
{{ else if eq $proto "fastcgi" }}
|
||||||
root {{ trim $vhost_root }};
|
root {{ trim $vhost_root }};
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_pass {{ trim $container.Name }};
|
fastcgi_pass {{ trim $container.Name }};
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
{{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }}
|
||||||
|
proxy_pass {{ trim $proto }}://{{ trim $container.Name }}/;
|
||||||
|
{{ else }}
|
||||||
proxy_pass {{ trim $proto }}://{{ trim $container.Name }};
|
proxy_pass {{ trim $proto }}://{{ trim $container.Name }};
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
|
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
|
||||||
auth_basic "Restricted {{ $host }}";
|
auth_basic "Restricted {{ $host }}";
|
||||||
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
|
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
|
||||||
|
|
Loading…
Reference in a new issue