mirror of
https://github.com/thib8956/nginx-proxy
synced 2024-11-22 20:06:30 +00:00
Merge pull request #671 from thomasleveil/regex-end-of-line
fix crash when using end-of-string symbol `$` in regex VIRTUAL_HOST
This commit is contained in:
commit
f1ccde2fe3
13
nginx.tmpl
13
nginx.tmpl
@ -85,8 +85,9 @@ server {
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
|
{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
|
||||||
|
{{ $upstream_name := sha1 $host }}
|
||||||
upstream {{ $host }} {
|
# {{ $host }}
|
||||||
|
upstream {{ $upstream_name }} {
|
||||||
{{ range $container := $containers }}
|
{{ range $container := $containers }}
|
||||||
{{ $addrLen := len $container.Addresses }}
|
{{ $addrLen := len $container.Addresses }}
|
||||||
|
|
||||||
@ -179,9 +180,9 @@ server {
|
|||||||
location / {
|
location / {
|
||||||
{{ if eq $proto "uwsgi" }}
|
{{ if eq $proto "uwsgi" }}
|
||||||
include uwsgi_params;
|
include uwsgi_params;
|
||||||
uwsgi_pass {{ trim $proto }}://{{ trim $host }};
|
uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }};
|
||||||
{{ else }}
|
{{ else }}
|
||||||
proxy_pass {{ trim $proto }}://{{ trim $host }};
|
proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
|
||||||
{{ 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 }}";
|
||||||
@ -213,9 +214,9 @@ server {
|
|||||||
location / {
|
location / {
|
||||||
{{ if eq $proto "uwsgi" }}
|
{{ if eq $proto "uwsgi" }}
|
||||||
include uwsgi_params;
|
include uwsgi_params;
|
||||||
uwsgi_pass {{ trim $proto }}://{{ trim $host }};
|
uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }};
|
||||||
{{ else }}
|
{{ else }}
|
||||||
proxy_pass {{ trim $proto }}://{{ trim $host }};
|
proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
|
||||||
{{ 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 }}";
|
||||||
|
@ -43,13 +43,28 @@ function setup {
|
|||||||
|
|
||||||
@test "[$TEST_FILE] VIRTUAL_HOST=~^foo\.bar\..*\.bats" {
|
@test "[$TEST_FILE] VIRTUAL_HOST=~^foo\.bar\..*\.bats" {
|
||||||
# WHEN
|
# WHEN
|
||||||
prepare_web_container bats-wildcard-hosts-2 80 -e VIRTUAL_HOST=~^foo\.bar\..*\.bats
|
prepare_web_container bats-wildcard-hosts-3 80 -e VIRTUAL_HOST=~^foo\.bar\..*\.bats
|
||||||
dockergen_wait_for_event $SUT_CONTAINER start bats-wildcard-hosts-2
|
dockergen_wait_for_event $SUT_CONTAINER start bats-wildcard-hosts-3
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# THEN
|
# THEN
|
||||||
assert_200 foo.bar.whatever.bats
|
assert_200 foo.bar.whatever.bats
|
||||||
assert_200 foo.bar.why.not.bats
|
assert_200 foo.bar.why.not.bats
|
||||||
|
assert_200 foo.bar.why.not.bats-to-infinity-and-beyond
|
||||||
|
assert_503 unexpected.host.bats
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "[$TEST_FILE] VIRTUAL_HOST=~^foo\.bar\..*\.bats$" {
|
||||||
|
# WHEN
|
||||||
|
prepare_web_container bats-wildcard-hosts-4 80 -e VIRTUAL_HOST=~^foo\.bar\..*\.bats$
|
||||||
|
dockergen_wait_for_event $SUT_CONTAINER start bats-wildcard-hosts-4
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
# THEN
|
||||||
|
assert_200 foo.bar.whatever.bats
|
||||||
|
assert_200 foo.bar.why.not.bats
|
||||||
|
assert_503 foo.bar.why.not.bats-to-infinity-and-beyond
|
||||||
assert_503 unexpected.host.bats
|
assert_503 unexpected.host.bats
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user