diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 620e43e9..c397cce8 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -63,6 +63,13 @@ jobs: grep --fixed-strings '

It works!

' /tmp/out + curl -v --compressed localhost:8888/FooBar 2>&1 | tee /tmp/out + + grep --fixed-strings 'HTTP/1.1 301 Moved Permanently' /tmp/out + grep --fixed-strings '< x-rewrite: 1' /tmp/out + grep --fixed-strings '< Location: http://localhost/foobar' /tmp/out + + curl -v --compressed https://localhost:8889 2>&1 | tee /tmp/h2 grep --fixed-strings '< HTTP/2 200' /tmp/h2 diff --git a/nginx.conf b/nginx.conf index ab2347c9..31130637 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,10 +1,17 @@ +# this allows you to call directives such as "env" in your own conf files +# http://nginx.org/en/docs/ngx_core_module.html#env +# +# and load dynamic modules via load_module +# http://nginx.org/en/docs/ngx_core_module.html#load_module +include /etc/nginx/main.d/*.conf; + + user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; - events { worker_connections 1024; } @@ -34,6 +41,3 @@ http { include /etc/nginx/conf.d/*.conf; } -# this allows you to call directives such as "env" in your own conf files -# http://nginx.org/en/docs/ngx_core_module.html#env -include /etc/nginx/main.d/*.conf; diff --git a/run-docker.sh b/run-docker.sh index c2d08dc3..a494f7aa 100755 --- a/run-docker.sh +++ b/run-docker.sh @@ -4,6 +4,8 @@ docker run --rm \ -p 0.0.0.0:8889:443/tcp \ -p 0.0.0.0:8889:443/udp \ -v "$PWD/tests":/static:ro \ + -v "$PWD/tests/modules.conf":/etc/nginx/main.d/modules.conf:ro \ + -v "$PWD/tests/perl_rewrite.conf":/etc/nginx/conf.d/perl_rewrite.conf:ro \ -v "$PWD/tests/static.conf":/etc/nginx/conf.d/static.conf:ro \ -v "$PWD/tests/https.conf":/etc/nginx/conf.d/https.conf:ro \ -v "$PWD/tests/localhost.crt":/etc/nginx/ssl/localhost.crt:ro \ diff --git a/tests/modules.conf b/tests/modules.conf new file mode 100644 index 00000000..79ab57ec --- /dev/null +++ b/tests/modules.conf @@ -0,0 +1,2 @@ +load_module modules/ngx_http_geoip_module.so; +load_module modules/ngx_http_perl_module.so; diff --git a/tests/perl_rewrite.conf b/tests/perl_rewrite.conf new file mode 100644 index 00000000..7bf4e7dd --- /dev/null +++ b/tests/perl_rewrite.conf @@ -0,0 +1,7 @@ +# https://www.rewriteguide.com/nginx-enforce-lower-case-urls/ +perl_set $uri_lowercase 'sub { + my $r = shift; + my $uri = $r->uri; + $uri = lc($uri); + return $uri; +}'; diff --git a/tests/static.conf b/tests/static.conf index d38b590e..3812d57d 100644 --- a/tests/static.conf +++ b/tests/static.conf @@ -10,4 +10,9 @@ server { expires 1d; } + + location ~ [A-Z] { + add_header x-rewrite 1; + rewrite ^(.*)$ $scheme://$host$uri_lowercase permanent; + } }