Self-Hosting Federated Identity SSO with High Security on 4GB RAM VPS using Zitadel or Authentik
This guide shows how to self-host a high-security Federated Identity Single Sign-On (SSO) solution on a 4GB RAM VPS using Zitadel or Authentik, two open-source platforms ideal for...
Image credit: geralt · Pixabay Content License
Federated Identity Single Sign-On (SSO) enables users to log in once and access multiple applications without re-entering credentials, improving both security and user experience. This guide walks through self-hosting a high-security SSO solution on a 4GB RAM VPS using Zitadel or Authentik—two popular open-source platforms ideal for enterprises that want full control over their authentication infrastructure without relying on SaaS providers.
Introduction to Federated Identity and SSO
Federated Identity allows trusted organizations to authenticate users through a third-party identity provider (IdP), such as Zitadel or Authentik, instead of managing user accounts individually. Single Sign-On (SSO) is a key component of federated identity, enabling users to log in once and gain access to multiple linked applications. This approach reduces password fatigue, lowers IT overhead, and enhances security by centralizing authentication at a single trusted point.
Self-hosting SSO on a 4GB RAM VPS is feasible with modern open-source tools like Zitadel and Authentik, which are optimized for performance and scalability. With proper configuration, including firewalls, DDoS protection, and regular updates, such a setup can support secure authentication for small to medium enterprises.
Requirements and Preparation
To deploy the solution, prepare the following:
- A 4GB RAM or higher VPS running Linux (Ubuntu 22.04 or Debian 11).
- A public IP address and SSH access.
- A dedicated domain (e.g., auth.yourdomain.com) for the SSO interface.
- HTTPS configured (use Let's Encrypt for free certificates).
- Docker and Docker Compose installed (Kubernetes optional for scaling).
- Basic knowledge of networking, DNS, and web security.
Refer to the guide on Basic VPS DDoS Protection with Fail2Ban, Cloudflare, and iptables for foundational security setup.
Deploying Zitadel or Authentik on VPS
Choose between Zitadel (focused on high security, OAuth 2.0, OpenID Connect, SAML) or Authentik (user-friendly, easy to configure, rich app integrations).
Deploy Zitadel:
docker run -d \
--name zitadel \
-p 80:80 \
-p 443:443 \
-e ZITADEL_HTTP_HOST=auth.yourdomain.com \
-e ZITADEL_HTTPS=true \
-e ZITADEL_DB_TYPE=postgres \
-e ZITADEL_DB_HOST=postgres \
-e ZITADEL_DB_USER=zitadel \
-e ZITADEL_DB_PASS=zitadelpass \
-e ZITADEL_DB_NAME=zitadel \
-e ZITADEL_OIDC_CLIENT_ID=your-client-id \
-e ZITADEL_OIDC_CLIENT_SECRET=your-client-secret \
zitadel/zitadel:latest
Deploy Authentik:
docker-compose up -d
In docker-compose.yml:
version: '3.8'
services:
authentik:
image: goauthentik/authentik:latest
ports:
- "443:443"
environment:
- AK_DATABASE_TYPE=postgresql
- AK_DATABASE_HOST=postgres
- AK_DATABASE_USER=authentik
- AK_DATABASE_PASSWORD=authentikpass
- AK_DATABASE_NAME=authentik
- AK_SERVER_HOSTNAME=auth.yourdomain.com
- AK_SERVER_PORT=443
- AK_SERVER_SSL_ENABLED=true
depends_on:
- postgres
postgres:
image: postgres:14
environment:
- POSTGRES_USER=authentik
- POSTGRES_PASSWORD=authentikpass
- POSTGRES_DB=authentik
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
After deployment, access the admin interface via your configured domain and set up users, groups, applications, and authentication policies.
Authentication and Application Integration
To integrate applications (e.g., Nextcloud, GitLab, or internal apps), configure them to use Zitadel or Authentik as the Identity Provider (IdP).
Example: Integrating with Nextcloud
- In Nextcloud, go to Settings > Authentication > External authentication.
- Select SAML or OpenID Connect, depending on the platform.
- Enter the Entity ID, ACS URL, and metadata from Zitadel/Authentik.
- Ensure HTTPS is enforced and verify SSL certificates.
See the guide on Self-Hosting Moodle on High-Security Docker Container Clusters for Enterprises for additional integration examples.
Verification and Troubleshooting
Verification:
- Access your domain (auth.yourdomain.com) to confirm the service is running.
- Run
docker psto verify Zitadel/Authentik containers are active. - Test login to integrated apps and check authentication logs.
Troubleshooting:
- If access fails, check firewall rules (iptables, UFW) and ensure ports 80/443 are open.
- If authentication fails, verify SAML/OpenID Connect configuration and HTTPS certificate validity.
- If the service doesn't start, inspect logs with
docker logs zitadelordocker logs authentik.
Performance Optimization:
- Host the VPS on DPTCloud’s infrastructure for 99.98% SLA reliability: Network Security & 99.98% SLA Infrastructure at DPTCloud.
- Integrate Cloudflare for enhanced security and traffic offloading.
- Regularly back up databases and configuration files.
References
- Zitadel Documentation: https://zitadel.com/docs
- Authentik Documentation: https://goauthentik.io/docs
- Guide to Self-Hosting Moodle on High-Security Docker Container Clusters for Enterprises: https://dptcloud.com/en/blog/huong-dan-tu-host-moodle-tren-cum-docker-container-bao-mat-cao-cho-doanh-nghiep
Recommended NVMe Cloud VPS Plans to Deploy This Setup
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-3E
10% VAT included
- CPU: 2 vCPU
- RAM: 4 GB
- SSD: 50 GB NVMe
