Deployment
Deploying the server to a production environment should be relatively seamless, however some issues may come up regarding some of the topics below.
We will keep this guide up to date as more questions arise!
#
HTTPSIf you are directing HTTPS traffic to the server, you must tell the client module to connect via HTTPS and WSS as well.
This is as simple as changing the http
and ws
prefix to https
and wss
.
Example
Server:
Client:
#
Deploying on an existing serverIn the scenario where you already have a NodeJS server running, and you want to deploy the Collaboration server on the same server, you can create a reverse proxy to route requests to their intended destination.
For example, pretend you have an existing Express application with an existing API, like so:
Now, pretend we want to add the Collaboration server to the application.
The issue that arises is that we can only serve one application on port 80, meaning we can't serve both our existing API and the collab server over HTTP.
The solution is to write a simple reverse proxy using express. This reverse proxy will forward requests to either the collab server or your existing API depending on the path.
We'll be using http-proxy-middleware
to write our proxy, so start off with installing that:
Now, we can set up our proxy. Calls to our existing API will be prefixed with /api
, and our collab server will be prefixed with /collab
.
Since the proxy will be running on port 80 (HTTP), we also need to change our existing API to run on a different port.
After the changes above, our server behaves like so:
- Requests to
http://yourdomain.com/api/*
get redirected to port 3000, which is your existing API server - Requests to
http://yourdomain.com/collab/subscribe/*
get redirected to port 8000, which the collab server is listening to. - Requests to
http://yourdomain.com/collab/*
get redirected to port 8000, which the collab server is listening to.
Now, when setting up the client, you just need to include these paths for the url
and subscriptionUrl
params