Adding a [server] proxy-fix-enable-x-prefix configuration option to take into consideration the X-Forwarded-Prefix HTTP header (#639)

This commit is contained in:
Lucas Cimon 2020-04-22 16:44:26 +02:00 committed by GitHub
parent a548fbf45b
commit 080ee36371
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,6 +82,14 @@ logging.basicConfig(
logger = logging.getLogger("isso") 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): class Isso(object):
def __init__(self, conf): def __init__(self, conf):
@ -202,7 +210,7 @@ def make_app(conf=None, threading=True, multiprocessing=False, uwsgi=False):
allowed=("Origin", "Referer", "Content-Type"), allowed=("Origin", "Referer", "Content-Type"),
exposed=("X-Set-Cookie", "Date"))) exposed=("X-Set-Cookie", "Date")))
wrapper.extend([wsgi.SubURI, ProxyFix]) wrapper.extend([wsgi.SubURI, ProxyFixCustom])
if werkzeug.version.startswith("0.8"): if werkzeug.version.startswith("0.8"):
wrapper.append(wsgi.LegacyWerkzeugMiddleware) wrapper.append(wsgi.LegacyWerkzeugMiddleware)