Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Add security recommendation for firewall configuration in self-hosting documentation

Bill Yang0b9a1f702eab
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
new file mode 100644
index 000000000..613048222
--- /dev/null
+++ b/docker-compose.dev.yml
@@ -0,0 +1,103 @@
+services:
+ caddy:
+ image: caddy:latest
+ container_name: caddy
+ restart: unless-stopped
+ ports:
+ - "80:80"
+ - "443:443"
+ - "443:443/udp" # Needed for HTTP/3
+ volumes:
+ - ./Caddyfile:/etc/caddy/Caddyfile # Mount Caddy config file
+ - caddy_data:/data # Mount persistent data volume for certs etc.
+ - caddy_config:/config # Mount persistent config volume
+ environment:
+ # Pass domain name for use in Caddyfile
+ # Email is configured via Caddyfile global options
+ - DOMAIN_NAME=${DOMAIN_NAME}
+ depends_on:
+ - backend
+ - client
+
+ clickhouse:
+ container_name: clickhouse
+ image: clickhouse/clickhouse-server:latest
+ ports:
+ - "8123:8123"
+ - "9000:9000"
+ volumes:
+ - clickhouse-data:/var/lib/clickhouse
+ environment:
+ - CLICKHOUSE_DB=analytics
+ - CLICKHOUSE_USER=default
+ - CLICKHOUSE_PASSWORD=frog
+ healthcheck:
+ test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8123/ping"]
+ interval: 3s
+ timeout: 5s
+ retries: 5
+ start_period: 10s
+ restart: unless-stopped
+
+ postgres:
+ image: postgres:latest
+ container_name: postgres
+ environment:
+ POSTGRES_USER: frog
+ POSTGRES_PASSWORD: frog
+ POSTGRES_DB: analytics
+ volumes:
+ - postgres-data:/var/lib/postgresql/data
+ restart: unless-stopped
+ ports:
+ - "5432:5432"
+
+ backend:
+ container_name: backend
+ build:
+ context: ./server
+ dockerfile: Dockerfile
+ environment:
+ - NODE_ENV=production
+ - CLICKHOUSE_HOST=http://clickhouse:8123
+ - CLICKHOUSE_DB=analytics
+ - CLICKHOUSE_PASSWORD=frog
+ - POSTGRES_HOST=postgres
+ - POSTGRES_PORT=5432
+ - POSTGRES_DB=analytics
+ - POSTGRES_USER=frog
+ - POSTGRES_PASSWORD=frog
+ - BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}
+ - BASE_URL=${BASE_URL}
+ - STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY}
+ - STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET}
+ - CLOUD=${CLOUD}
+ depends_on:
+ clickhouse:
+ condition: service_healthy
+ postgres:
+ condition: service_started
+ restart: unless-stopped
+ ports:
+ - "3001:3001"
+
+ client:
+ container_name: client
+ build:
+ context: ./client
+ dockerfile: Dockerfile
+ args:
+ NEXT_PUBLIC_BACKEND_URL: ${BASE_URL}
+ environment:
+ - NODE_ENV=production
+ - NEXT_PUBLIC_BACKEND_URL=${BASE_URL}
+ - CLOUD=${CLOUD}
+ depends_on:
+ - backend
+ restart: unless-stopped
+
+volumes:
+ clickhouse-data:
+ postgres-data:
+ caddy_data: # Persistent volume for Caddy's certificates and state
+ caddy_config: # Persistent volume for Caddy's configuration cache (optional but good practice)
diff --git a/docs/src/content/self-hosting.mdx b/docs/src/content/self-hosting.mdx
index 18443190a..99f0a05cd 100644
--- a/docs/src/content/self-hosting.mdx
+++ b/docs/src/content/self-hosting.mdx
@@ -73,4 +73,22 @@ Create your admin account. You can then log in and start adding your websites!
Congratulations! You have successfully self-hosted Rybbit.
+## Security Recommendation: Firewall Configuration
+
+For enhanced security, it is highly recommended to configure a firewall on your VPS. Allow incoming connections only on the ports necessary for the application to function externally. In most standard setups, this means allowing traffic only on port `443` (HTTPS).
+
+The exact commands depend on the firewall software used (e.g., `ufw` for Ubuntu, `firewalld` for CentOS).
+
+Example using `ufw` (Uncomplicated Firewall) on Ubuntu:
+```bash
+sudo ufw allow ssh # Keep SSH access (usually port 22)
+sudo ufw allow 443/tcp # Allow HTTPS traffic
+sudo ufw enable # Enable the firewall
+sudo ufw status # Check the status
+```
+
+<Callout type="warning">
+Ensure you allow SSH access (typically port 22) before enabling the firewall, otherwise you might lock yourself out of your VPS!
+</Callout>
+
If you run into any issues or need help, feel free to join our Discord community!