Fix proxied logging X-Forwarded-For IP address.
This commit is contained in:
parent
c319c6fd58
commit
8656b02403
1 changed files with 9 additions and 2 deletions
|
|
@ -6,7 +6,6 @@ vlogging.earlybird_config()
|
|||
|
||||
import gevent.monkey; gevent.monkey.patch_all()
|
||||
import werkzeug.middleware.proxy_fix
|
||||
|
||||
import argparse
|
||||
import gevent.pywsgi
|
||||
import os
|
||||
|
|
@ -24,10 +23,16 @@ import backend
|
|||
|
||||
site = backend.site
|
||||
site.wsgi_app = werkzeug.middleware.proxy_fix.ProxyFix(site.wsgi_app)
|
||||
site.debug = True
|
||||
site.debug = False
|
||||
|
||||
HTTPS_DIR = pathclass.Path(__file__).parent.with_child('https')
|
||||
|
||||
def fix_proxied_logging(method):
|
||||
def format_request(self, *a, **k):
|
||||
self.client_address = self.headers.get('X-Forwarded-For', self.client_address)
|
||||
return method(self, *a, **k)
|
||||
return format_request
|
||||
|
||||
####################################################################################################
|
||||
|
||||
def etiquette_flask_launch(
|
||||
|
|
@ -52,6 +57,8 @@ def etiquette_flask_launch(
|
|||
application=site,
|
||||
)
|
||||
|
||||
http.handler_class.format_request = fix_proxied_logging(http.handler_class.format_request)
|
||||
|
||||
if localhost_only:
|
||||
log.info('Setting localhost_only=True')
|
||||
site.localhost_only = True
|
||||
|
|
|
|||
Loading…
Reference in a new issue