Workspace with Traefik, OAuth2, and TLS
This guide explains how to deploy the workspace container with Traefik reverse proxy, OAuth2 authentication, and TLS/HTTPS support for secure multi-user deployments.
❓ Prerequisites
✅ Docker Engine v27 or later
✅ Docker Compose v2.x
✅ Sufficient system resources (at least 1GB RAM per workspace instance)
✅ Valid TLS certificates (production) or self-signed certs (testing)
✅ Domain name pointing to the server (production) or localhost (testing)
🗒️ Design
The docker-compose.yml file provides a production-ready setup with:
- Traefik reverse proxy with TLS termination (ports 80, 443)
- Automatic HTTP to HTTPS redirect
- OAuth2 authentication via traefik-forward-auth
- Multiple workspace instances (user1, user2) behind authentication
- Secure communication with TLS certificates
- Workspace containers (for each user) using the workspace image
- Docker networks defined in
docker-compose.ymlto isolate frontend, auth, and user workspaces - Two Docker networks:
dtaas-frontendanddtaas-users
⚙️ Initial Configuration
Follow the steps in configuration.md
for creating suitable configuration.
Create Workspace Files
All the deployment options require user directories for
storing workspace files. These need to
be created for USERNAME1 and USERNAME2 set in
.env file.
Start Services
To start all services with TLS:
This will:
- Start Traefik reverse proxy with TLS on ports 80 (HTTP → HTTPS redirect) and 443 (HTTPS)
- Start traefik-forward-auth service for OAuth2 authentication
- Start workspace instances for user1 and user2, protected by authentication
Accessing Workspaces
Once all services are running, access the workspaces through Traefik with HTTPS:
User Workspace (workspace)
- VNC Desktop:
https://intocps.org/user1/tools/vnc?path=user1%2Ftools%2Fvnc%2Fwebsockify - VS Code:
https://intocps.org/user1/tools/vscode - Jupyter Notebook:
https://intocps.org/user1 - Jupyter Lab:
https://intocps.org/user1/lab
Service Discovery
The workspace provides a /services endpoint that returns a JSON list of
available services. This enables dynamic service discovery for frontend
applications.
Example: Get service list for user1
Response:
The endpoint values are dynamically populated with the user's username from the
MAIN_USER environment variable. This variable corresponds to USERNAME1 of
.env file.
🔒 Authentication Flow
- User attempts to access a workspace URL
- Traefik forwards the request to traefik-forward-auth
- If not authenticated, user is redirected to OAuth2 provider
- User logs in with OAuth2 provider
- Provider redirects back with authorisation code
- traefik-forward-auth exchanges code for token and creates session
- User is redirected to original URL and gains access
🛑 Stopping Services
To stop all services:
To stop and remove volumes:
🔧 Customization
Adding More Users
To add additional workspace instances, add a new service in docker-compose.yml:
Add the desired USERNAME3 variable in .env:
Add Forward Auth config for user3 in forward-auth-conf:
Ensure that the username and email correspond to the workspaces user.
Do not forget to create the user's directory:
Bring up the user workspace.
🐛 Troubleshooting
Certificate Issues
Problem: "NET::ERR_CERT_INVALID" in browser
Solutions:
- Verify certificate files exist in
./certs/directory - Check certificate file permissions
- Ensure
dynamic/tls.ymlcorrectly references certificate paths - For self-signed certs, add security exception in browser
OAuth2 Issues
Problem: Redirect loop after OAuth2 login
Solutions:
- Verify OAuth2 callback URL matches
https://intocps.org/_oauth - Check
SERVER_DNSenvironment variable is set correctly - Ensure
COOKIE_DOMAINmatches the domain - Verify OAuth2 application is approved and active
Port Conflicts
Problem: Ports 80 or 443 already in use
Solutions:
- Check for other services:
sudo netstat -tlnp | grep -E ':(80|443)' - Stop conflicting services
- Or modify port mappings in compose file (not recommended for production)