loolwsd/FileServer.hpp | 2 +- loolwsd/LOOLWSD.cpp | 41 +++++++++++++++++++++++++++++++++++++---- loolwsd/LOOLWSD.hpp | 7 +++++++ loolwsd/Makefile.am | 2 ++ loolwsd/Storage.cpp | 2 +- loolwsd/favicon.ico |binary loolwsd/loolwsd.spec.in | 1 + loolwsd/loolwsd.xml.in | 1 + 8 files changed, 50 insertions(+), 6 deletions(-)
New commits: commit af71a9be15953c2b0c72004243e8a04d6c7afa9a Author: Andras Timar <andras.ti...@collabora.com> Date: Sun Aug 28 21:41:28 2016 +0200 loolwsd: add support of SSL termination diff --git a/loolwsd/FileServer.hpp b/loolwsd/FileServer.hpp index 874db99..3bcf113 100644 --- a/loolwsd/FileServer.hpp +++ b/loolwsd/FileServer.hpp @@ -217,7 +217,7 @@ private: { HTMLForm form(request, request.stream()); - const auto host = (LOOLWSD::isSSLEnabled() ? "wss://" : "ws://") + (LOOLWSD::ServerName.empty() ? request.getHost() : LOOLWSD::ServerName); + const auto host = ((LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()) ? "wss://" : "ws://") + (LOOLWSD::ServerName.empty() ? request.getHost() : LOOLWSD::ServerName); const auto path = Poco::Path(LOOLWSD::FileServerRoot, getRequestPathname(request)); Log::debug("Preprocessing file: " + path.toString()); diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index c14e986..e9ce1d6 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -782,7 +782,7 @@ private: const std::string urlsrc = "urlsrc"; const auto& config = Application::instance().config(); const std::string loleafletHtml = config.getString("loleaflet_html", "loleaflet.html"); - const std::string uriValue = (LOOLWSD::isSSLEnabled() ? "https://" : "http://") + + const std::string uriValue = ((LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()) ? "https://" : "http://") + (LOOLWSD::ServerName.empty() ? request.getHost() : LOOLWSD::ServerName) + "/loleaflet/" LOOLWSD_VERSION_HASH "/" + loleafletHtml + "?"; @@ -1240,7 +1240,7 @@ std::string lcl_getLaunchURI() aAbsTopSrcDir = Poco::Path(aAbsTopSrcDir).absolute().toString(); std::string aLaunchURI(" "); - aLaunchURI += ((LOOLWSD::isSSLEnabled()) ? "https://" : "http://"); + aLaunchURI += ((LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()) ? "https://" : "http://"); aLaunchURI += LOOLWSD_TEST_HOST ":"; aLaunchURI += std::to_string(ClientPortNumber); aLaunchURI += LOOLWSD_TEST_LOLEAFLET_UI; @@ -1263,6 +1263,7 @@ std::string LOOLWSD::ServerName; std::string LOOLWSD::FileServerRoot; std::string LOOLWSD::LOKitVersion; Util::RuntimeConstant<bool> LOOLWSD::SSLEnabled; +Util::RuntimeConstant<bool> LOOLWSD::SSLTermination; static std::string UnitTestLibrary; @@ -1322,6 +1323,7 @@ void LOOLWSD::initialize(Application& self) { "logging.color", "true" }, { "logging.level", "trace" }, { "ssl.enable", "true" }, + { "ssl.termination", "true" }, { "ssl.cert_file_path", LOOLWSD_CONFIGDIR "/cert.pem" }, { "ssl.key_file_path", LOOLWSD_CONFIGDIR "/key.pem" }, { "ssl.ca_file_path", LOOLWSD_CONFIGDIR "/ca-chain.cert.pem" }, @@ -1367,6 +1369,12 @@ void LOOLWSD::initialize(Application& self) Log::warn("SSL support: SSL is disabled."); } +#if ENABLE_SSL + LOOLWSD::SSLTermination.set(getConfigValue<bool>(conf, "ssl.termination", true)); +#else + LOOLWSD::SSLTermination.set(false); +#endif + Cache = getPathFromConfig("tile_cache_path"); SysTemplate = getPathFromConfig("sys_template_path"); LoTemplate = getPathFromConfig("lo_template_path"); diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp index ff282d6..bfc1310 100644 --- a/loolwsd/LOOLWSD.hpp +++ b/loolwsd/LOOLWSD.hpp @@ -57,6 +57,12 @@ public: { return LOOLWSD::SSLEnabled.get(); } + static + bool isSSLTermination() + { + return LOOLWSD::SSLTermination.get(); + } + protected: void initialize(Poco::Util::Application& self) override; @@ -67,6 +73,7 @@ protected: private: static Util::RuntimeConstant<bool> SSLEnabled; + static Util::RuntimeConstant<bool> SSLTermination; void initializeSSL(); void displayHelp(); diff --git a/loolwsd/Storage.cpp b/loolwsd/Storage.cpp index 3fc75b7..9f1694e 100644 --- a/loolwsd/Storage.cpp +++ b/loolwsd/Storage.cpp @@ -241,7 +241,7 @@ namespace { static inline Poco::Net::HTTPClientSession* lcl_getHTTPClientSession(const Poco::URI& uri) { - return (LOOLWSD::isSSLEnabled()) ? new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort(), Poco::Net::SSLManager::instance().defaultClientContext()) + return (LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()) ? new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort(), Poco::Net::SSLManager::instance().defaultClientContext()) : new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort()); } diff --git a/loolwsd/loolwsd.xml.in b/loolwsd/loolwsd.xml.in index 6366dd6..880fa5c 100644 --- a/loolwsd/loolwsd.xml.in +++ b/loolwsd/loolwsd.xml.in @@ -27,6 +27,7 @@ <ssl desc="SSL settings"> <enable type="bool" default="true">true</enable> + <termination desc="Connection via proxy where loolwsd acts as working via https, but actually uses http." type="bool" default="true">true</termination> <cert_file_path desc="Path to the cert file" relative="false">/etc/loolwsd/cert.pem</cert_file_path> <key_file_path desc="Path to the key file" relative="false">/etc/loolwsd/key.pem</key_file_path> <ca_file_path desc="Path to the ca file" relative="false">/etc/loolwsd/ca-chain.cert.pem</ca_file_path> commit 5ee7380e3409824c216b87e9d5df7e6af3119178 Author: Andras Timar <andras.ti...@collabora.com> Date: Fri Aug 26 13:40:20 2016 +0200 loolwsd: response to HTTP GET or HEAD / (e.g. for checking if server is alive) (cherry picked from commit a5aa138774b028d2f366f24ce3ec8371d7e31e3a) (cherry picked from commit 274d68644d8adf20628e92c3d5e55f9687196adb) diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 93be99b..c14e986 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -851,7 +851,21 @@ public: bool responded = false; try { - if (request.getMethod() == HTTPRequest::HTTP_GET && request.getURI() == "/favicon.ico") + if ((request.getMethod() == HTTPRequest::HTTP_GET || request.getMethod() == HTTPRequest::HTTP_HEAD) && request.getURI() == "/") + { + std::string mimeType = "text/plain"; + std::string responseString = "OK"; + response.setContentLength(responseString.length()); + response.setContentType(mimeType); + response.setChunkedTransferEncoding(false); + std::ostream& ostr = response.send(); + if (request.getMethod() == HTTPRequest::HTTP_GET) + { + ostr << responseString; + } + responded = true; + } + else if (request.getMethod() == HTTPRequest::HTTP_GET && request.getURI() == "/favicon.ico") { std::string mimeType = "image/vnd.microsoft.icon"; std::string faviconPath = Path(Application::instance().commandPath()).parent().toString() + "favicon.ico"; commit 11c4f821f61aa36c0d22f731e5746f22f681973c Author: Andras Timar <andras.ti...@collabora.com> Date: Fri Aug 26 12:57:33 2016 +0200 loolwsd: add favicon (cherry picked from commit 619ddb4c2f06bcd22e69f4498dc4730a5e1d2eed) diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 240064b..93be99b 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -851,7 +851,19 @@ public: bool responded = false; try { - if (request.getMethod() == HTTPRequest::HTTP_GET && request.getURI() == "/hosting/discovery") + if (request.getMethod() == HTTPRequest::HTTP_GET && request.getURI() == "/favicon.ico") + { + std::string mimeType = "image/vnd.microsoft.icon"; + std::string faviconPath = Path(Application::instance().commandPath()).parent().toString() + "favicon.ico"; + if (!File(faviconPath).exists()) + { + faviconPath = LOOLWSD_DATADIR "/favicon.ico"; + } + response.setContentType(mimeType); + response.sendFile(faviconPath, mimeType); + responded = true; + } + else if (request.getMethod() == HTTPRequest::HTTP_GET && request.getURI() == "/hosting/discovery") { // http://server/hosting/discovery responded = handleGetWOPIDiscovery(request, response); @@ -1148,7 +1160,6 @@ public: logger << Log::end; // Routing - // FIXME: Some browsers (all?) hit for /favicon.ico. Create a nice favicon and add to routes Poco::URI requestUri(request.getURI()); std::vector<std::string> reqPathSegs; requestUri.getPathSegments(reqPathSegs); diff --git a/loolwsd/Makefile.am b/loolwsd/Makefile.am index 85081d1..98f1061 100644 --- a/loolwsd/Makefile.am +++ b/loolwsd/Makefile.am @@ -9,6 +9,7 @@ dist_bin_SCRIPTS = loolwsd-systemplate-setup loolwsddatadir = @LOOLWSD_DATADIR@ loolwsddata_DATA = discovery.xml \ + favicon.ico \ robots.txt loolwsdconfigdir = @LOOLWSD_CONFIGDIR@ @@ -111,6 +112,7 @@ noinst_HEADERS = Admin.hpp \ security.h EXTRA_DIST = discovery.xml \ + favicon.ico \ loolwsd.xml.in \ loolwsd.service \ robots.txt \ diff --git a/loolwsd/favicon.ico b/loolwsd/favicon.ico new file mode 100644 index 0000000..10c0557 Binary files /dev/null and b/loolwsd/favicon.ico differ diff --git a/loolwsd/loolwsd.spec.in b/loolwsd/loolwsd.spec.in index 3814682..f444cce 100644 --- a/loolwsd/loolwsd.spec.in +++ b/loolwsd/loolwsd.spec.in @@ -103,6 +103,7 @@ tar cf - . | (cd %{buildroot}/usr/share/loolwsd/loleaflet && tar xf -) /usr/bin/loolmount /usr/bin/looltool /usr/share/loolwsd/discovery.xml +/usr/share/loolwsd/favicon.ico /usr/share/loolwsd/robots.txt /usr/share/loolwsd/loleaflet %{_unitdir}/loolwsd.service _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits