aboutsummaryrefslogtreecommitdiff
path: root/stackbin.py
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2022-02-14 22:49:17 -0500
committerB Stack <bgstack15@gmail.com>2022-02-14 22:49:17 -0500
commitc364901df2ef04553fc7508c31446ad14ac93737 (patch)
tree7f2441778eba0661195024484122e55754e52bcd /stackbin.py
parentadd initial centos7 doc (diff)
downloadstackbin-c364901df2ef04553fc7508c31446ad14ac93737.tar.gz
stackbin-c364901df2ef04553fc7508c31446ad14ac93737.tar.bz2
stackbin-c364901df2ef04553fc7508c31446ad14ac93737.zip
r-proxy support with /set endpoint, and extra dir
The extra dir is still WIP
Diffstat (limited to 'stackbin.py')
-rwxr-xr-xstackbin.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/stackbin.py b/stackbin.py
index bcfd3d5..e8948fd 100755
--- a/stackbin.py
+++ b/stackbin.py
@@ -5,6 +5,7 @@ from datetime import datetime, timedelta
from itsdangerous import Signer
from flask import (Flask, request, url_for, redirect, g, render_template, session, abort)
from flask_sqlalchemy import SQLAlchemy
+from werkzeug.middleware.proxy_fix import ProxyFix
from pytimeparse.timeparse import timeparse # python3-pytimeparse
# uwsgidecorators load will fail when using initdb.py but is also not necessary
try:
@@ -283,5 +284,13 @@ def favicon():
except:
abort(404)
+@app.route('/set')
+def get_proxied_path():
+ if 'HTTP_X_FORWARDED_PREFIX' in request.environ:
+ pl = len(dict(request.headers)["X-Forwarded-Host"].split(", "))
+ #prefix = request.environ['HTTP_X_FORWARDED_PREFIX']
+ app.wsgi_app = ProxyFix(app.wsgi_app,x_for=pl,x_host=pl,x_port=pl,x_prefix=pl,x_proto=pl)
+ return redirect(url_for('new_paste'))
+
if __name__ == "__main__":
app.run()
bgstack15