Support parsing xheaders in tornado

That will give us more accurate client ips, with a one hop limitation
however, see http://www.tornadoweb.org/en/stable/httpserver.html. If
more than one hop/reverse proxy is used in front of OctoPrint, their IPs
should be configured as server.reverseProxy.trustedDownstream in
config.yaml so they don't get detected as client IPs.

Implements #2512
This commit is contained in:
Gina Häußge committed 2018-03-27 14:54:52 +02:00
1 parent da392b9c9f
commit 64ee8bac60
3 files changed
+20 -3

No files matched your search

+9 -1
View File
@@ -617,7 +617,15 @@ class Server(object):
self._stop_intermediary_server()
# initialize and bind the server
self._server = util.tornado.CustomHTTPServer(self._tornado_app, max_body_sizes=max_body_sizes, default_max_body_size=self._settings.getInt(["server", "maxSize"]))
trusted_downstream = self._settings.get(["server", "reverseProxy", "trustedDownstream"])
if not isinstance(trusted_downstream, list):
self._logger.warn("server.reverseProxy.trustedDownstream is not a list, skipping")
trusted_downstreams = []
self._server = util.tornado.CustomHTTPServer(self._tornado_app,
max_body_sizes=max_body_sizes,
default_max_body_size=self._settings.getInt(["server", "maxSize"]),
xheaders=True,
trusted_downstream=trusted_downstream)
self._server.listen(self._port, address=self._host)
### From now on it's ok to launch subprocesses again
+2 -1
View File
@@ -164,7 +164,8 @@ default_settings = {
"schemeFallback": None,
"hostFallback": None,
"serverFallback": None,
"portFallback": None
"portFallback": None,
"trustedDownstream": []
},
"uploads": {
"maxSize": 1 * 1024 * 1024 * 1024, # 1GB