Skip to content

Commit 71e1395

Browse files
security(ui): add Basic Auth protection for /accounts UI
- Add Traefik Basic Auth middleware for /accounts path - API endpoints remain unprotected (as intended) - Configure via CCPROXY_UI_AUTH environment variable - Document setup in .env.example BREAKING: /accounts UI now requires authentication when CCPROXY_UI_AUTH is set
1 parent 445d6cb commit 71e1395

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ PGID=1000
3838
# Hostname for Traefik routing (Docker compose with Traefik)
3939
# CCPROXY_HOST=localhost
4040

41+
# =============================================================================
42+
# UI SECURITY (Traefik Basic Auth)
43+
# =============================================================================
44+
# Basic Auth credentials for /accounts UI (protects account management)
45+
# Generate with: htpasswd -nb username password
46+
# Example: htpasswd -nb admin mySecurePassword123
47+
# IMPORTANT: In docker-compose, escape $ as $$ (admin:$$apr1$$...)
48+
# CCPROXY_UI_AUTH=admin:$$apr1$$SALT$$HASH
49+
4150
# =============================================================================
4251
# DEBUGGING & LOGGING
4352
# =============================================================================

docker/compose.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,28 @@ services:
3535
labels:
3636
- traefik.enable=true
3737
- traefik.docker.network=coolify
38+
# HTTP → HTTPS redirect
3839
- 'traefik.http.routers.claude-code-proxy-http.rule=Host(`${CCPROXY_HOST:-localhost}`)'
3940
- traefik.http.routers.claude-code-proxy-http.entrypoints=http
4041
- traefik.http.routers.claude-code-proxy-http.middlewares=redirect-to-https
41-
- 'traefik.http.routers.claude-code-proxy.rule=Host(`${CCPROXY_HOST:-localhost}`)'
42+
- traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
43+
- traefik.http.middlewares.redirect-to-https.redirectscheme.permanent=true
44+
# Main HTTPS router (API access - no auth)
45+
- 'traefik.http.routers.claude-code-proxy.rule=Host(`${CCPROXY_HOST:-localhost}`) && !PathPrefix(`/accounts`)'
4246
- traefik.http.routers.claude-code-proxy.entrypoints=https
4347
- traefik.http.routers.claude-code-proxy.tls=true
4448
- traefik.http.routers.claude-code-proxy.tls.certresolver=letsencrypt
49+
# Protected UI router (accounts - requires Basic Auth)
50+
- 'traefik.http.routers.claude-code-proxy-ui.rule=Host(`${CCPROXY_HOST:-localhost}`) && PathPrefix(`/accounts`)'
51+
- traefik.http.routers.claude-code-proxy-ui.entrypoints=https
52+
- traefik.http.routers.claude-code-proxy-ui.tls=true
53+
- traefik.http.routers.claude-code-proxy-ui.tls.certresolver=letsencrypt
54+
- traefik.http.routers.claude-code-proxy-ui.middlewares=accounts-auth
55+
# Basic Auth middleware (generate hash: htpasswd -nb admin password)
56+
# Default: admin:admin - CHANGE THIS via CCPROXY_UI_AUTH env var
57+
- 'traefik.http.middlewares.accounts-auth.basicauth.users=${CCPROXY_UI_AUTH:-admin:$$apr1$$xyz$$placeholder}'
58+
# Service
4559
- traefik.http.services.claude-code-proxy.loadbalancer.server.port=8000
46-
- traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
47-
- traefik.http.middlewares.redirect-to-https.redirectscheme.permanent=true
4860
networks:
4961
- coolify
5062

0 commit comments

Comments
 (0)