diff --git a/CHANGELOG.md b/CHANGELOG.md index d5db9e5e..22c8a8ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ by versioneer * [IRC] Don't hiccup on slic3r filament_diameter comments generated for multi extruder setups * [ML] Fixed relative URL to sockjs endpoint, wasn't yet using the proper base url +* [unreported] Generated URLs now take X-Forwarded-Host header sent by proxies into account for included host and port * Small fixes for timelapse creation: - [#344](https://github.com/foosel/OctoPrint/issues/344) - Made timelapses capable of coping with missing captures in between by decrementing the image counter again if there was an error fetching the latest image from the snapshot URL (backport of [1a7a468](https://github.com/foosel/OctoPrint/commit/1a7a468eb65fdf2a13b4c7a7723280e822c9c34b) diff --git a/src/octoprint/server/util.py b/src/octoprint/server/util.py index 71149686..4e03d49a 100644 --- a/src/octoprint/server/util.py +++ b/src/octoprint/server/util.py @@ -373,6 +373,14 @@ class ReverseProxied(object): if scheme: environ['wsgi.url_scheme'] = scheme + + host = environ.get('HTTP_X_FORWARDED_HOST', '') + if not host: + host = settings().get(["server", "host"]) + + if host: + environ['HTTP_HOST'] = host + return self.app(environ, start_response)