diff --git a/common/ASC.Socket.IO/app/portalManager.js b/common/ASC.Socket.IO/app/portalManager.js index 9fb4f19cfc..de3bedd169 100644 --- a/common/ASC.Socket.IO/app/portalManager.js +++ b/common/ASC.Socket.IO/app/portalManager.js @@ -1,21 +1,6 @@ -//const conf = require("../config"); -//const portalInternalUrl = conf.get("core")["base-domain"] === "localhost" ? "http://localhost" : ""; //Do not use base-domain for portalInternalUrl -module.exports = (req) => { - //if (portalInternalUrl) return portalInternalUrl; //TODO: Fix internal api url setup after external api domain complete +module.exports = (req) => { + const proto = req.headers['x-forwarded-proto']?.split(',').shift(); + const host = req.headers['x-forwarded-host']?.split(',').shift(); - const xRewriterUrlInternalHeader = "x-rewriter-url-internal"; - if (req.headers && req.headers[xRewriterUrlInternalHeader]) { - return req.headers[xRewriterUrlInternalHeader]; - } - - const xRewriterUrlHeader = "x-rewriter-url"; - if (req.headers && req.headers[xRewriterUrlHeader]) { - return req.headers[xRewriterUrlHeader]; - } - - if (req?.headers?.origin) { - return req.headers.origin; - } - - return ""; + return `${proto}://${host}`; }; diff --git a/common/ASC.SsoAuth/app/utils/resolver.js b/common/ASC.SsoAuth/app/utils/resolver.js index eb27e3a1bb..22f185392d 100644 --- a/common/ASC.SsoAuth/app/utils/resolver.js +++ b/common/ASC.SsoAuth/app/utils/resolver.js @@ -25,8 +25,10 @@ const config = require("../../config").get(), module.exports = function () { function getBaseUrl(req) { - const url = req.headers["x-rewriter-url"] || req.protocol + "://" + req.get("host"); - return url; + const proto = req.headers['x-forwarded-proto']?.split(',').shift(); + const host = req.headers['x-forwarded-host']?.split(',').shift(); + + return `${proto}://${host}`; } function getPortalSsoHandlerUrl(req) { diff --git a/common/ASC.WebDav/server/requestAPI.js b/common/ASC.WebDav/server/requestAPI.js index ef430513dd..0f55f3900c 100644 --- a/common/ASC.WebDav/server/requestAPI.js +++ b/common/ASC.WebDav/server/requestAPI.js @@ -37,15 +37,10 @@ const renamingDuplicateElements = require('../helper/renamingDuplicateElements.j function getDomain(ctx) { - const rewriterUrl = ctx.headers.headers["x-rewriter-url"]; + const proto = ctx.headers.headers['x-forwarded-proto']?.split(',').shift(); + const host = ctx.headers.headers['x-forwarded-host']?.split(',').shift(); - if (rewriterUrl) { - return rewriterUrl; - } - - const protocol = isHttps ? "https://" : "http://"; - const hostStr = ctx.headers.host; - return protocol + hostStr.split(":")[0] + onlyOfficePort; + return `${proto}://${host}`; } function instanceFunc(ctx, token = null, header = 'application/json', service = 'asc.files') { diff --git a/config/nginx/onlyoffice.conf b/config/nginx/onlyoffice.conf index a9b8f4a7ea..f6822b89d9 100644 --- a/config/nginx/onlyoffice.conf +++ b/config/nginx/onlyoffice.conf @@ -90,7 +90,6 @@ server { proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl; proxy_set_header X-Forwarded-Host $proxy_x_forwarded_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-REWRITER-URL $X_REWRITER_URL; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $proxy_connection; proxy_set_header Proxy ""; diff --git a/packages/common/utils/axiosClient.js b/packages/common/utils/axiosClient.js index bde80f1b42..682993f974 100644 --- a/packages/common/utils/axiosClient.js +++ b/packages/common/utils/axiosClient.js @@ -57,9 +57,10 @@ class AxiosClient { initSSR = (headers) => { this.isSSR = true; - const xRewriterUrl = headers["x-rewriter-url"]; - - const origin = apiOrigin || xRewriterUrl; + const proto = headers['x-forwarded-proto']?.split(',').shift(); + const host = headers['x-forwarded-host']?.split(',').shift(); + + const origin = apiOrigin || `${proto}://${host}`; const apiBaseURL = combineUrl(origin, proxyURL, apiPrefix);