瀏覽代碼

Requires ~() in location to remove $request_uri and removes $request_uri if it is just a slash

Julian Reinhardt 4 年之前
父節點
當前提交
c203d1a0d8
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      backend/templates/_location.conf

+ 6 - 1
backend/templates/_location.conf

@@ -1,5 +1,10 @@
   location {{ path }} {
-    set              $targetUri {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }}{% unless path contains "(" %}$request_uri{% endunless %};
+    set              $targetUri {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }};
+    {% unless path contains "~" and path contains "(" and path contains ")" %}
+    if ($request_uri != /){
+      set            $targetUri $targetUri$request_uri;
+    }
+    {% endunless %}
     proxy_set_header Host $host;
     proxy_set_header X-Forwarded-Scheme $scheme;
     proxy_set_header X-Forwarded-Proto  $scheme;