Nymspace is a pseudonym-based chat app built by the Berkman Center. Nymspace is organized into two repos:
- nymspace_server - a node.js/express/socket.io/mongodb/mongoose chat server
- nymspace_client - a vue.js application that consumes the server APIs and presents a chat application to participants.
This third repo contains documentation for self-hosting and deploying nymspace frontend and backend to a production environment.
We provide a single file deployment with docker compose in docker-compose.yml.
- Create an .env file based on .env.example
- edit the env variables and replace things like example.com with your domain
- Deploy the compose file with your favorite docker management tool
- Configure a proxy server
We provide a sample nginx file in nymspace.conf.
If you're using a tool like nginx proxy manager, you can:
- Add a main entry pointing your domain to the ip address of your container host
- Point to port 8080 or whichever port you set in the docker-compose
- Enable websocket support
- Add these locations to your proxy host:
- Location:
/v1/
→ Forward tonymspace-backend:3000
- Location:
/socket.io/
→ Forward tonymspace-backend:5555
- Location:
- Update, upgrade and lockdown your server
- Install node and yarn using your favorite package manager or tool manager (we like [https://volta.sh])
- Install PM2 globally
- Install
mongodb
(ubuntu 24 server) - Pull the latest code from github.com/berkmancenter/nymspace_server
- Create a production env file based on .env.example
- Copy the code to the server e.g.
git clone [email protected]:berkmancenter/nymspace_server.git
cp nymspace_server/.env.example cp nymspace_server/.env
rsync -avx ./nymspace_server/ [email protected]:nymspace_server
- ssh into your server, cd into the repo, and
yarn start
, e.g.
ssh [email protected]
cd ~/nymspace_server && yarn start
- Pull the latest code from github.com/berkmancenter/nymspace_client
- Update create an
.env.local
that looks like this (replacing example.com with your target production domain):
VITE_API_VERSION=v1
VITE_API_SERVER_URL=https://example.com
VITE_WEBSOCKET_SERVER_URL=https://example.com
- Run
yarn build
- Copy the built files to your webserver, e.g.
rsync -avx ./nymspace_client/dist/ [email protected]:/var/www/nymspace_client/dist
- Back on the server, install nginx
- sudo nano
/etc/nginx/sites-available/example.com.conf
and include the template from nymspace.conf ln -s /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/example.com.conf
sudo systemctl restart nginx
- make sure that the permissions are correctly set on
/var/www/nymspace_client/dist
for nginx to read them - Install and run lets encrypt to provide SSL for your domain (this will edit your nginx conf and configure ssl termination and redirects as needed)
- Make sure you built the front end with the correct urls for the backend APIs
- Make sure the backend started successfully
- Check that your proxy is properly configured for WebSocket support
VITE_API_VERSION
: API version (default: v1)VITE_API_SERVER_URL
: Full URL to your serverVITE_WEBSOCKET_SERVER_URL
: WebSocket server URL (mostt likely the same as above)JWT_SECRET
: Secret key for JWT tokens (make a random string)AUTH_TOKEN_SECRET
: Secret for authentication token (make a random string)
MAX_MESSAGE_LENGTH
: How long a message can be (default: 2000)NYMSPACE_ENABLE_AGENTS
: Enable AI agents (default: false)NYMSPACE_ENABLE_POLLS
: Enable polls feature (default: false)NYMSPACE_ENABLE_PUBLIC_CHANNEL_CREATION
: Allow users to create public channels (default: false)
SMTP_HOST
: SMTP server hostnameSMTP_PORT
: SMTP server portSMTP_USERNAME
: SMTP usernameSMTP_PASSWORD
: SMTP passwordEMAIL_FROM
: From email address
OPENAI_API_KEY
: OpenAI API key for AI featuresLANGCHAIN_API_BASE_PATH
: LangChain API base pathPERSPECTIVE_API_KEY
: Google Perspective API key for content moderation