Closed ksylvan closed 7 years ago
I'm running the wonderfall/boring-nginx image with this configuration:
wonderfall/boring-nginx
nginx: image: wonderfall/boring-nginx container_name: nginx # restart: always ports: - "80:8000" - "443:4430" volumes: - /mnt/docker/nginx/sites-enabled:/sites-enabled - /mnt/docker/nginx/conf:/conf.d - /mnt/docker/nginx/log:/var/log/nginx - /mnt/docker/mail/ssl/selfsigned:/certs - /mnt/docker/www:/www
One of the sites-enabled is for www.test.net:
sites-enabled
www.test.net
server { listen 8000; server_name www.test.net; return 301 https://$host$request_uri; } server { listen 4430 ssl http2; server_name www.test.net; ssl_certificate /certs/cert.pem; ssl_certificate_key /certs/privkey.pem; include /etc/nginx/conf/ssl_params; include /etc/nginx/conf/headers_params; location ~ ^/~(.+?)(/.*)?$ { alias /www/people/$1$2; index index.html index.htm; } location / { root /www/files; index index.html index.htm; } }
The files installed in /mnt/docker/www are as follows:
/mnt/docker/www
/mnt/docker/www/ ├── files │ ├── index.html │ └── robots.txt └── people └── abc └── index.html
When I try to get `/~abc/' I get the expected result:
$ curl -I -k https://www.test.net/~abc/ HTTP/2 200 date: Mon, 18 Sep 2017 06:27:08 GMT content-type: text/html content-length: 142 last-modified: Mon, 18 Sep 2017 06:05:09 GMT vary: Accept-Encoding etag: "59bf6215-8e" server: secret x-frame-options: SAMEORIGIN x-content-type-options: nosniff x-xss-protection: 1; mode=block accept-ranges: bytes
But when I try the same with `/~abc' (note that there is no ending /) nginx redirects to port 4430:
$ curl -I -k https://www.test.net/~abc HTTP/2 301 date: Mon, 18 Sep 2017 06:28:25 GMT content-type: text/html content-length: 178 location: https://www.test.net:4430/~abc/ server: secret x-frame-options: SAMEORIGIN x-content-type-options: nosniff x-xss-protection: 1; mode=block
Any ideas for how I can work around this?
Thanks to @kambiz-aghaiepour for this. Added this snippet to the site config to fix the issue.
location ~ ^[^.]*[^/]$ { try_files $uri @rewrite; } location @rewrite { return 302 $scheme://$http_host$uri/; }
I'm running the
wonderfall/boring-nginx
image with this configuration:One of the
sites-enabled
is forwww.test.net
:The files installed in
/mnt/docker/www
are as follows:When I try to get `/~abc/' I get the expected result:
But when I try the same with `/~abc' (note that there is no ending /) nginx redirects to port 4430:
Any ideas for how I can work around this?