aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2023-08-30 15:24:17 -0400
committerB. Stack <bgstack15@gmail.com>2023-08-30 15:24:43 -0400
commitf02ba6fdf5a9c1b87c8208b9251d51d791922df2 (patch)
tree1fd356ccd59ede6d75adf810a3b4dd989f3cebef
parentcustomize css (diff)
downloadnewspipe-f02ba6fdf5a9c1b87c8208b9251d51d791922df2.tar.gz
newspipe-f02ba6fdf5a9c1b87c8208b9251d51d791922df2.tar.bz2
newspipe-f02ba6fdf5a9c1b87c8208b9251d51d791922df2.zip
add support for reverse-proxy in config
-rw-r--r--instance/config.py2
-rw-r--r--newspipe/bootstrap.py11
2 files changed, 13 insertions, 0 deletions
diff --git a/instance/config.py b/instance/config.py
index af5fe9b9..81f83f12 100644
--- a/instance/config.py
+++ b/instance/config.py
@@ -10,6 +10,8 @@ PORT = 5000
DEBUG = True
API_ROOT = "/api/v2.0"
+PREFIX = "/newspipe"
+
CSRF_ENABLED = True
SECRET_KEY = "LCx3BchmHRxFzkEv4BqQJyeXRLXenf"
SECURITY_PASSWORD_SALT = "L8gTsyrpRQEF8jNWQPyvRfv7U5kJkD"
diff --git a/newspipe/bootstrap.py b/newspipe/bootstrap.py
index 12044916..3905cd93 100644
--- a/newspipe/bootstrap.py
+++ b/newspipe/bootstrap.py
@@ -44,9 +44,20 @@ def set_logging(
handler.setLevel(log_level)
logger.setLevel(log_level)
+class ReverseProxied(object):
+ def __init__(self, app, script_name):
+ self.app = app
+ self.script_name = script_name
+
+ def __call__(self, environ, start_response):
+ environ['SCRIPT_NAME'] = self.script_name
+ return self.app(environ, start_response)
+
# Create Flask application
application = Flask(__name__, instance_relative_config=True)
+if "PREFIX" in application.config:
+ application.wsgi_app = ReverseProxied(application.wsgi_app, script_name=application.config["PREFIX"])
configuration = os.environ.get("NEWSPIPE_CONFIG", False)
if configuration == "testing":
application.debug = logging.DEBUG
bgstack15