Skip to content

Commit 43a66fb

Browse files
authored
Merge pull request #53 from macbre/test-dynamic-modules
Test loading of dynamic modules
2 parents 2c4e966 + 2e2fa64 commit 43a66fb

File tree

6 files changed

+31
-4
lines changed

6 files changed

+31
-4
lines changed

.github/workflows/dockerimage.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ jobs:
6363
grep --fixed-strings '<p>It works!</p>' /tmp/out
6464
6565
66+
curl -v --compressed localhost:8888/FooBar 2>&1 | tee /tmp/out
67+
68+
grep --fixed-strings 'HTTP/1.1 301 Moved Permanently' /tmp/out
69+
grep --fixed-strings '< x-rewrite: 1' /tmp/out
70+
grep --fixed-strings '< Location: http://localhost/foobar' /tmp/out
71+
72+
6673
curl -v --compressed https://localhost:8889 2>&1 | tee /tmp/h2
6774
6875
grep --fixed-strings '< HTTP/2 200' /tmp/h2

nginx.conf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
# this allows you to call directives such as "env" in your own conf files
2+
# http://nginx.org/en/docs/ngx_core_module.html#env
3+
#
4+
# and load dynamic modules via load_module
5+
# http://nginx.org/en/docs/ngx_core_module.html#load_module
6+
include /etc/nginx/main.d/*.conf;
7+
8+
19
user nginx;
210
worker_processes 1;
311

412
error_log /var/log/nginx/error.log warn;
513
pid /var/run/nginx.pid;
614

7-
815
events {
916
worker_connections 1024;
1017
}
@@ -34,6 +41,3 @@ http {
3441
include /etc/nginx/conf.d/*.conf;
3542
}
3643

37-
# this allows you to call directives such as "env" in your own conf files
38-
# http://nginx.org/en/docs/ngx_core_module.html#env
39-
include /etc/nginx/main.d/*.conf;

run-docker.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ docker run --rm \
44
-p 0.0.0.0:8889:443/tcp \
55
-p 0.0.0.0:8889:443/udp \
66
-v "$PWD/tests":/static:ro \
7+
-v "$PWD/tests/modules.conf":/etc/nginx/main.d/modules.conf:ro \
8+
-v "$PWD/tests/perl_rewrite.conf":/etc/nginx/conf.d/perl_rewrite.conf:ro \
79
-v "$PWD/tests/static.conf":/etc/nginx/conf.d/static.conf:ro \
810
-v "$PWD/tests/https.conf":/etc/nginx/conf.d/https.conf:ro \
911
-v "$PWD/tests/localhost.crt":/etc/nginx/ssl/localhost.crt:ro \

tests/modules.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
load_module modules/ngx_http_geoip_module.so;
2+
load_module modules/ngx_http_perl_module.so;

tests/perl_rewrite.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# https://www.rewriteguide.com/nginx-enforce-lower-case-urls/
2+
perl_set $uri_lowercase 'sub {
3+
my $r = shift;
4+
my $uri = $r->uri;
5+
$uri = lc($uri);
6+
return $uri;
7+
}';

tests/static.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ server {
1010

1111
expires 1d;
1212
}
13+
14+
location ~ [A-Z] {
15+
add_header x-rewrite 1;
16+
rewrite ^(.*)$ $scheme://$host$uri_lowercase permanent;
17+
}
1318
}

0 commit comments

Comments
 (0)