From 1ee8d177b40a3b7d3e11975437948bb614b2bc55 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 10 Jan 2022 14:49:53 -0800 Subject: [PATCH] fix(docker): rewrite trailing slashes to non-trailing in nginx config Without this rewriting, we've been running into conversing with HTTP over HTTPS (400 Bad Request). TODO: Refactor this entire nginx config to something a bit more simple and clean. Signed-off-by: Kevin Morris --- docker/config/nginx.conf | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/docker/config/nginx.conf b/docker/config/nginx.conf index c60bb3d9..b5c09d08 100644 --- a/docker/config/nginx.conf +++ b/docker/config/nginx.conf @@ -94,6 +94,8 @@ http { ssl_certificate /etc/ssl/certs/web.cert.pem; ssl_certificate_key /etc/ssl/private/web.key.pem; + rewrite ^/(.*)/$ /$1 permanent; + location ~ ^/[^\/]+\.gz$ { # Override mime type to text/plain. types { text/plain gz; } @@ -113,10 +115,6 @@ http { add_header ETag ""; } - location / { - try_files $uri @proxy_to_app; - } - location ~ "^/([a-z0-9][a-z0-9.+_-]*?)(\.git)?/(git-(receive|upload)-pack|HEAD|info/refs|objects/(info/(http-)?alternates|packs)|[0-9a-f]{2}/[0-9a-f]{38}|pack/pack-[0-9a-f]{40}\.(pack|idx))$" { include uwsgi_params; uwsgi_pass smartgit; @@ -136,13 +134,12 @@ http { uwsgi_pass uwsgi://cgit-fastapi; } - location @proxy_to_app { + location / { + proxy_pass http://asgi_backend; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - proxy_redirect off; - proxy_buffering off; - proxy_pass http://asgi_backend; + proxy_set_header X-Forwarded-Ssl on; } }