Add in proxy for /socket.io so that we don't need to faff with real-time service location

This commit is contained in:
James Allen 2015-03-09 14:09:09 +00:00
parent bb61dfe34a
commit 0f69ee0f22
4 changed files with 17 additions and 0 deletions

View file

@ -0,0 +1,12 @@
settings = require "settings-sharelatex"
httpProxy = require('http-proxy');
proxy = httpProxy.createProxyServer({
target: settings.apis.realTime.url
ws: true
})
module.exports =
apply: (app) ->
app.all /\/socket\.io\/.*/, (req, res, next) ->
proxy.web req, res, next

View file

@ -34,6 +34,7 @@ BlogController = require("./Features/Blog/BlogController")
WikiController = require("./Features/Wiki/WikiController") WikiController = require("./Features/Wiki/WikiController")
Modules = require "./infrastructure/Modules" Modules = require "./infrastructure/Modules"
RateLimiterMiddlewear = require('./Features/Security/RateLimiterMiddlewear') RateLimiterMiddlewear = require('./Features/Security/RateLimiterMiddlewear')
RealTimeProxyRouter = require('./Features/RealTimeProxy/RealTimeProxyRouter')
logger = require("logger-sharelatex") logger = require("logger-sharelatex")
_ = require("underscore") _ = require("underscore")
@ -62,6 +63,7 @@ module.exports = class Router
UploadsRouter.apply(app) UploadsRouter.apply(app)
PasswordResetRouter.apply(app) PasswordResetRouter.apply(app)
StaticPagesRouter.apply(app) StaticPagesRouter.apply(app)
RealTimeProxyRouter.apply(app)
Modules.applyRouter(app) Modules.applyRouter(app)

View file

@ -100,6 +100,8 @@ module.exports =
subdomain: "" subdomain: ""
geoIpLookup: geoIpLookup:
url: "http://localhost:8080/json" url: "http://localhost:8080/json"
realTime:
url: "http://localhost:3026"
templates: templates:
user_id: process.env.TEMPLATES_USER_ID or "5395eb7aad1f29a88756c7f2" user_id: process.env.TEMPLATES_USER_ID or "5395eb7aad1f29a88756c7f2"

View file

@ -18,6 +18,7 @@
"dateformat": "1.0.4-1.2.3", "dateformat": "1.0.4-1.2.3",
"express": "3.3.4", "express": "3.3.4",
"fairy": "0.0.2", "fairy": "0.0.2",
"http-proxy": "^1.8.1",
"jade": "~1.3.1", "jade": "~1.3.1",
"ldapjs": "^0.7.1", "ldapjs": "^0.7.1",
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.0.0", "logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.0.0",