diff --git a/CHANGELOG b/CHANGELOG index 6b50ef248e..73a55a9409 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Manage 'X-Forwarded' headers from proxies * Add '_request' attribute to Transaction context * Delete translations on deletion only when model has translatable field * Remove MySQL backend diff --git a/doc/topics/configuration.rst b/doc/topics/configuration.rst index d91c35da73..1835e5f6c1 100644 --- a/doc/topics/configuration.rst +++ b/doc/topics/configuration.rst @@ -54,6 +54,13 @@ Defines the root path served by `GET` requests. Default: Under the `www` directory of user's home running `trytond`. +num_proxies +~~~~~~~~~~~ + +The number of proxy servers in front of `trytond`. + +Default: 0 + database -------- diff --git a/trytond/config.py b/trytond/config.py index 2c2a72a228..7dd0db1a87 100644 --- a/trytond/config.py +++ b/trytond/config.py @@ -44,6 +44,7 @@ class TrytonConfigParser(ConfigParser.RawConfigParser): self.add_section('web') self.set('web', 'listen', 'localhost:8000') self.set('web', 'root', os.path.join(os.path.expanduser('~'), 'www')) + self.set('web', 'num_proxies', 0) self.add_section('database') self.set('database', 'uri', os.environ.get('TRYTOND_DATABASE_URI', 'sqlite://')) diff --git a/trytond/wsgi.py b/trytond/wsgi.py index f6ef004863..e3b102aa2a 100644 --- a/trytond/wsgi.py +++ b/trytond/wsgi.py @@ -8,6 +8,7 @@ import traceback from werkzeug.wrappers import Response from werkzeug.routing import Map, Rule from werkzeug.exceptions import abort, HTTPException, InternalServerError +from werkzeug.contrib.fixers import ProxyFix import wrapt @@ -118,4 +119,7 @@ class TrytondWSGI(object): return self.wsgi_app(environ, start_response) app = TrytondWSGI() +num_proxies = config.getint('web', 'num_proxies') +if num_proxies: + app.wsgi_app = ProxyFix(app.wsgi_app, num_proxies=num_proxies) import trytond.protocols.dispatcher