mirror of https://github.com/CIRCL/lookyloo
chg: Properly handle proxied setups
parent
a39f857216
commit
ccd73c302a
|
@ -7,7 +7,7 @@ server {
|
||||||
proxy_set_header Host $http_host;
|
proxy_set_header Host $http_host;
|
||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Scheme $scheme;
|
proxy_set_header X_FORWARDED_PROTO $scheme;
|
||||||
proxy_connect_timeout 300;
|
proxy_connect_timeout 300;
|
||||||
proxy_read_timeout 300;
|
proxy_read_timeout 300;
|
||||||
proxy_pass http://localhost:5100/;
|
proxy_pass http://localhost:5100/;
|
||||||
|
|
|
@ -16,12 +16,14 @@ from flask_httpauth import HTTPDigestAuth # type: ignore
|
||||||
from lookyloo.helpers import get_homedir, update_user_agents, get_user_agents
|
from lookyloo.helpers import get_homedir, update_user_agents, get_user_agents
|
||||||
from lookyloo.lookyloo import Lookyloo
|
from lookyloo.lookyloo import Lookyloo
|
||||||
from lookyloo.exceptions import NoValidHarFile
|
from lookyloo.exceptions import NoValidHarFile
|
||||||
|
from .proxied import ReverseProxied
|
||||||
|
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
app: Flask = Flask(__name__)
|
app: Flask = Flask(__name__)
|
||||||
|
app.wsgi_app = ReverseProxied(app.wsgi_app)
|
||||||
|
|
||||||
secret_file_path: Path = get_homedir() / 'secret_key'
|
secret_file_path: Path = get_homedir() / 'secret_key'
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
class ReverseProxied():
|
||||||
|
def __init__(self, app):
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
def __call__(self, environ, start_response):
|
||||||
|
scheme = environ.get('HTTP_X_FORWARDED_PROTO')
|
||||||
|
if not scheme:
|
||||||
|
scheme = environ.get('HTTP_X_SCHEME')
|
||||||
|
|
||||||
|
if scheme:
|
||||||
|
environ['wsgi.url_scheme'] = scheme
|
||||||
|
return self.app(environ, start_response)
|
Loading…
Reference in New Issue