From 080ee3637108d985a0bd97dc1db99cc4f3a16f2e Mon Sep 17 00:00:00 2001 From: Lucas Cimon Date: Wed, 22 Apr 2020 16:44:26 +0200 Subject: [PATCH] Adding a [server] proxy-fix-enable-x-prefix configuration option to take into consideration the `X-Forwarded-Prefix` HTTP header (#639) --- isso/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/isso/__init__.py b/isso/__init__.py index 90a4da8..64a6546 100644 --- a/isso/__init__.py +++ b/isso/__init__.py @@ -82,6 +82,14 @@ logging.basicConfig( logger = logging.getLogger("isso") +class ProxyFixCustom(ProxyFix): + def __init__(self, app): + # This is needed for werkzeug.wsgi.get_current_url called in isso/views/comments.py + # to work properly when isso is hosted under a sub-path + # cf. https://werkzeug.palletsprojects.com/en/1.0.x/middleware/proxy_fix/ + super().__init__(app, x_prefix=1) + + class Isso(object): def __init__(self, conf): @@ -202,7 +210,7 @@ def make_app(conf=None, threading=True, multiprocessing=False, uwsgi=False): allowed=("Origin", "Referer", "Content-Type"), exposed=("X-Set-Cookie", "Date"))) - wrapper.extend([wsgi.SubURI, ProxyFix]) + wrapper.extend([wsgi.SubURI, ProxyFixCustom]) if werkzeug.version.startswith("0.8"): wrapper.append(wsgi.LegacyWerkzeugMiddleware)