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:
1 parent
da392b9c9f
commit
64ee8bac60
3 files changed
+20
-3
No files matched your search
@@ -934,7 +934,7 @@ Use the following settings to configure the server:
|
||||
|
||||
# Settings if OctoPrint is running behind a reverse proxy (haproxy, nginx, apache, ...).
|
||||
# These are necessary in order to make OctoPrint generate correct external URLs so
|
||||
# that AJAX requests and download URLs work.
|
||||
# that AJAX requests and download URLs work, and so that client IPs are read correctly.
|
||||
reverseProxy:
|
||||
|
||||
# The request header from which to determine the URL prefix under which OctoPrint
|
||||
@@ -968,6 +968,14 @@ Use the following settings to configure the server:
|
||||
# (X-Forwarded-Host by default, see above) with forwarded requests.
|
||||
hostFallback:
|
||||
|
||||
# List of trusted downstream servers for which to ignore the IP address when trying to determine
|
||||
# the connecting client's IP address. If you have OctoPrint behind more than one reverse proxy
|
||||
# you should add their IPs here so that they won't be interpreted as the client's IP. One reverse
|
||||
# proxy will be handled correctly by default.
|
||||
trustedDownstream:
|
||||
- 192.168.1.254
|
||||
- 192.168.23.42
|
||||
|
||||
# Settings for file uploads to OctoPrint, such as maximum allowed file size and
|
||||
# header suffixes to use for streaming uploads. OctoPrint does some nifty things internally in
|
||||
# order to allow streaming of large file uploads to the application rather than just storing
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -164,7 +164,8 @@ default_settings = {
|
||||
"schemeFallback": None,
|
||||
"hostFallback": None,
|
||||
"serverFallback": None,
|
||||
"portFallback": None
|
||||
"portFallback": None,
|
||||
"trustedDownstream": []
|
||||
},
|
||||
"uploads": {
|
||||
"maxSize": 1 * 1024 * 1024 * 1024, # 1GB
|
||||
|
||||
Reference in new issue
Block a user