From 87ddcac2fce893ef9c9d749c50623b98fc354bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 30 Dec 2014 10:20:50 +0100 Subject: [PATCH] Don't user server.host but server.forwardedHost as fallback for generated external URLs Closes #698 --- CHANGELOG.md | 8 +++++--- src/octoprint/server/util.py | 2 +- src/octoprint/settings.py | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22c8a8ab..87e44208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,11 @@ * [#634](https://github.com/foosel/OctoPrint/pull/634) - Fixed missing `branch` fields in version dicts generated 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 +* [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] & [#698](https://github.com/foosel/OctoPrint/issues/698) - Generated URLs now take X-Forwarded-Host header + sent by proxies into account for included host and port, also fixed [#698](https://github.com/foosel/OctoPrint/issues/698) + introduced by this * 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 4e03d49a..de782d26 100644 --- a/src/octoprint/server/util.py +++ b/src/octoprint/server/util.py @@ -376,7 +376,7 @@ class ReverseProxied(object): host = environ.get('HTTP_X_FORWARDED_HOST', '') if not host: - host = settings().get(["server", "host"]) + host = settings().get(["server", "forwardedHost"]) if host: environ['HTTP_HOST'] = host diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 0f70641f..259edaac 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -43,7 +43,8 @@ default_settings = { "firstRun": True, "secretKey": None, "baseUrl": "", - "scheme": "" + "scheme": "", + "forwardedHost": "" }, "webcam": { "stream": None,