Skip to content
This repository has been archived by the owner on Mar 2, 2021. It is now read-only.

Commit

Permalink
Add --proxy-fix option for HTTP reverse proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia authored and Crosspop committed Feb 11, 2013
1 parent fe12c90 commit b2eacfe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions asuka/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys

from waitress import serve
from werkzeug.contrib.fixers import ProxyFix
from werkzeug.wsgi import DispatcherMiddleware

from .config import app_from_config_file
Expand All @@ -27,6 +28,9 @@ def run_server():
'--pong=/ping/')
parser.add_option('--log-file', default='/dev/stderr',
help='File to write logs [default: %default]')
parser.add_option('--proxy-fix', action='store_true', default=False,
help='Forward X-Forwared-* headers to support HTTP '
'reverse proxies e.g. nginx, lighttpd')
parser.add_option('-v', '--verbose', action='store_true', default=False)
parser.add_option('-q', '--quiet', action='store_true', default=False)
options, args = parser.parse_args()
Expand Down Expand Up @@ -56,6 +60,8 @@ def run_server():
logger.addHandler(logging.StreamHandler(log_file))
app = app_from_config_file(config)
webapp = WebApp(app)
if options.proxy_fix:
webapp.wsgi_app = ProxyFix(webapp.wsgi_app)
def pong(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['pong']
Expand Down

0 comments on commit b2eacfe

Please sign in to comment.