diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2020-04-28 15:17:23 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2020-04-28 16:37:29 +0200 |
commit | c9ed710518725872a583ea31cac3b60178daa540 (patch) | |
tree | 7981ae17f5cd653f622ae025825fdccc873c52d3 /wsd/FileServer.cpp | |
parent | add more info to description of storage.ssl.ca_file_path setting (diff) | |
download | online-c9ed710518725872a583ea31cac3b60178daa540.tar.gz online-c9ed710518725872a583ea31cac3b60178daa540.zip |
Proxy: convert ProxyPrefix to a full URL.
Thus encoding the actual proxy's http/https state.
Change-Id: Ia7d5b8fb9379364b6c10a2c84d609f49e215ccb1
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93077
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'wsd/FileServer.cpp')
-rw-r--r-- | wsd/FileServer.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index 8073860c22..99ac332b31 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -647,15 +647,38 @@ namespace { if (!request.has("ProxyPrefix")) return LOOLWSD::ServiceRoot; std::string proxyPrefix = request.get("ProxyPrefix", ""); + + // skip url to the root path. + size_t pos = proxyPrefix.find("://"); + if (pos != std::string::npos) { + pos = proxyPrefix.find("/", pos + 3); + if (pos != std::string::npos) + proxyPrefix = proxyPrefix.substr(pos); + else + LOG_DBG("Unusual proxy prefix '" << proxyPrefix << "'"); + } else + LOG_DBG("No http[s]:// in unusual proxy prefix '" << proxyPrefix); return proxyPrefix; } + + std::string getWebSocketUrl(const HTTPRequest &request) + { + bool ssl = (LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()); + std::string proxyPrefix = request.get("ProxyPrefix", ""); + std::string serverName = LOOLWSD::ServerName.empty() ? request.getHost() : LOOLWSD::ServerName; + if (proxyPrefix.size() > 0) + { + ssl = !strcmp(proxyPrefix.c_str(), "https://"); + serverName = request.getHost(); + } + return (ssl ? "wss://" : "ws://") + serverName; + } } void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, Poco::MemoryInputStream& message, const std::shared_ptr<StreamSocket>& socket) { - const auto host = ((LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()) ? "wss://" : "ws://") - + (LOOLWSD::ServerName.empty() ? request.getHost() : LOOLWSD::ServerName); + const auto host = getWebSocketUrl(request); const Poco::URI::QueryParameters params = Poco::URI(request.getURI()).getQueryParameters(); // Is this a file we read at startup - if not; its not for serving. |