diff --git a/services/web/app/coffee/infrastructure/OldAssetProxy.coffee b/services/web/app/coffee/infrastructure/OldAssetProxy.coffee new file mode 100644 index 0000000000..1407d46eca --- /dev/null +++ b/services/web/app/coffee/infrastructure/OldAssetProxy.coffee @@ -0,0 +1,13 @@ +settings = require("settings-sharelatex") +logger = require("logger-sharelatex") +request = require("request") + +module.exports = (req, res, next)-> + requestedUrl = req.url + + redirectUrl = settings.proxyUrls[requestedUrl] + if redirectUrl? + logger.log redirectUrl:redirectUrl, reqUrl:req.url, "proxying url" + request(redirectUrl).pipe(res) + else + next() diff --git a/services/web/app/coffee/infrastructure/Server.coffee b/services/web/app/coffee/infrastructure/Server.coffee index 5eebdf9599..c5e131c9cf 100644 --- a/services/web/app/coffee/infrastructure/Server.coffee +++ b/services/web/app/coffee/infrastructure/Server.coffee @@ -17,6 +17,7 @@ cookieParser = express.cookieParser(Settings.security.sessionSecret) oneDayInMilliseconds = 86400000 ReferalConnect = require('../Features/Referal/ReferalConnect') RedirectManager = require("./RedirectManager") +OldAssetProxy = require("./OldAssetProxy") metrics.mongodb.monitor(Path.resolve(__dirname + "/../../../node_modules/mongojs/node_modules/mongodb"), logger) metrics.mongodb.monitor(Path.resolve(__dirname + "/../../../node_modules/mongoose/node_modules/mongodb"), logger) @@ -76,6 +77,7 @@ app.configure 'production', -> app.use metrics.http.monitor(logger) app.use RedirectManager +app.use OldAssetProxy app.use (req, res, next)-> metrics.inc "http-request" diff --git a/services/web/config/settings.defaults.coffee b/services/web/config/settings.defaults.coffee index 3c8f7f3882..6e674a7711 100644 --- a/services/web/config/settings.defaults.coffee +++ b/services/web/config/settings.defaults.coffee @@ -269,3 +269,5 @@ module.exports = redirects: "/templates/index": "/templates/" + proxyUrls: {} +