Merge pull request #2733 from dalf/fix-2656

SCRIPT_NAME remove trailing slash to avoid infinite redirect
This commit is contained in:
Noémi Ványi 2021-04-08 19:47:28 +02:00 committed by GitHub
commit a9a51ceb48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1133,11 +1133,14 @@ class ReverseProxyPathFix:
base_url = urlparse(settings['server']['base_url'])
self.script_name = base_url.path
if self.script_name.endswith('/'):
# remove trailing slash to avoid infinite redirect on the index
# see https://github.com/searx/searx/issues/2729
self.script_name = self.script_name[:-1]
self.scheme = base_url.scheme
self.server = base_url.netloc
def __call__(self, environ, start_response):
script_name = self.script_name or environ.get('HTTP_X_SCRIPT_NAME', '')
if script_name:
environ['SCRIPT_NAME'] = script_name