Home > Software > How to Deploy Authelia with Docker Compose: A Step-by-Step Guide

How to Deploy Authelia with Docker Compose: A Step-by-Step Guide

Anastasios Antoniadis

Learn how to deploy Authelia, the all-in-one authentication and authorization server, using Docker Compose with our comprehensive guide. Enhance your web applications’ security with 2FA, SSO, and LDAP integration effortlessly.

Docker (1)

Authelia is an open-source, full-featured authentication and authorization server that provides a secure gateway to protect your web applications. It supports several methods of authentication, including two-factor authentication (2FA), Single Sign-On (SSO), and LDAP integration, making it a versatile tool for enhancing the security of your online services. Deploying Authelia with Docker Compose simplifies the process, allowing for easy setup, scalability, and maintenance. This guide will walk you through setting up Authelia using Docker Compose, ensuring you have a robust authentication system in place for your applications.

Why Docker Compose?

Docker Compose facilitates the management of multi-container Docker applications. With a single command, you can configure and start all the components of your application based on a docker-compose.yml file. This approach is particularly beneficial for complex setups like Authelia, which might involve multiple services such as a web server, a Redis session store, and an LDAP server for user authentication.

Prerequisites

Before you begin, ensure Docker and Docker Compose are installed on your system. Basic knowledge of Docker, networking, and security concepts is also recommended.

Step 1: Create the Docker Compose File

The first step is to create a docker-compose.yml file in your project directory. This file will define the services necessary for Authelia, including Authelia itself, a Redis instance for session storage, and an optional LDAP server for user authentication.

Below is a basic example of a Docker Compose file for deploying Authelia. This setup assumes you use Authelia with Redis for session storage and an LDAP server for user authentication.

version: '3'

services:
  authelia:
    image: authelia/authelia
    container_name: authelia
    volumes:
      - ./authelia:/config
    ports:
      - "9091:9091"
    environment:
      - AUTHELIA_SESSION_REDIS_HOST=redis
      - AUTHELIA_SESSION_REDIS_PORT=6379
    depends_on:
      - redis

  redis:
    image: redis
    container_name: redis
    volumes:
      - redis-data:/data

  ldap:
    image: osixia/openldap:1.4.0
    container_name: ldap
    environment:
      - LDAP_ORGANISATION="My Org"
      - LDAP_DOMAIN="myorg.com"
      - LDAP_ADMIN_PASSWORD="admin"
    volumes:
      - ldap-data:/var/lib/ldap
      - ldap-config:/etc/ldap/slapd.d

volumes:
  redis-data:
  ldap-data:
  ldap-config:

Explanation of Docker Compose Components

  • authelia: The Authelia service with a mounted volume for configuration files and specified environment variables to connect to Redis.
  • redis: A Redis container for session storage, used by Authelia for managing session data.
  • ldap: An optional LDAP server container configured for user authentication. This service is included for environments requiring LDAP integration.
  • volumes: Persistent storage is defined for Redis and LDAP, ensuring data is retained across container restarts.

Step 2: Configuring Authelia

Before starting your containers, you’ll need to configure Authelia. This involves setting up the configuration files (configuration.yml and users_database.yml) within the ./authelia directory specified in the Docker Compose file. Authelia’s documentation provides detailed instructions on configuring these files based on your specific needs.

Step 3: Deploying with Docker Compose

With your Docker Compose file and Authelia configuration ready, deploy your services by running the following command in the directory containing your docker-compose.yml file:

docker compose up -d

This command will start all the defined services in the background.

Step 4: Verifying the Deployment

After deployment, ensure Authelia runs correctly by accessing its web interface, usually available at http://localhost:9091, unless you’ve configured it differently. You should be able to see the Authelia login page and proceed with setting up access to your applications.

Conclusion

Deploying Authelia with Docker Compose offers a streamlined and efficient way to set up a robust authentication system for your web applications. Following the steps in this guide, you can enhance your application security with features like 2FA and SSO, providing a secure and user-friendly authentication experience. Authelia’s flexibility and Docker Compose’s simplicity make this combination a powerful tool in your security arsenal.

Anastasios Antoniadis
Follow me
Latest posts by Anastasios Antoniadis (see all)
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x