Uncategorized

Any good guides to setup Traefik, Authentik and Crowdsec using docker compose to securely expose applications like Jellyfin or Nextcloud?

Simplifying Self-Hosted Security: A Guide to Traefik, Authentik, and Crowdsec

Securing Your Favorite Apps Like Jellyfin and Nextcloud with Docker Compose

As someone who’s ventured into the world of self-hosting, I’ve encountered my fair share of challenges. One of the most significant hurdles is securing my applications. I’ve spent countless hours searching for the perfect solution, and that’s when I stumbled upon Traefik, Authentik, and Crowdsec. But, like many others, I found it tough to set them up using Docker Compose, especially with the lack of updated guides. In this post, I’ll walk you through my journey and provide a step-by-step guide on how to securely expose your favorite apps like Jellyfin or Nextcloud using these powerful tools.

Why Traefik, Authentik, and Crowdsec?

So, why did I choose Traefik, Authentik, and Crowdsec? Well, each of these tools offers a unique set of features that make them ideal for self-hosting. Traefik is a reverse proxy and load balancer that allows you to expose your applications to the internet while keeping them secure. Authentik is an authentication server that enables you to manage access to your apps, and Crowdsec is a security tool that helps protect your server from malicious activity. By combining these tools, you can create a robust security system that safeguards your self-hosted applications.

Setting Up Traefik with Docker Compose

Before we dive into the setup process, make sure you have Docker and Docker Compose installed on your system. Once you’ve got that covered, create a new file named docker-compose.yml and add the following configuration:

version: '3'
services:
  traefik:
    image: traefik:v2.5
    ports:
      - "80:80"
    volumes:
      - ./traefik.yml:/etc/traefik/traefik.yml
      - ./acme.json:/etc/traefik/acme.json
      - /var/run/docker.sock:/var/run/docker.sock
    command: --log.level=DEBUG

This configuration sets up Traefik with the latest version and maps port 80 to your host machine. The traefik.yml file contains the configuration for Traefik, and the acme.json file stores the SSL certificates. The /var/run/docker.sock volume allows Traefik to communicate with Docker.

Configuring Authentik

Next, we’ll set up Authentik. Create a new file named authentik.yml and add the following configuration:

version: '3'
services:
  authentik:
    image: authentik/server:2022.10.1
    ports:
      - "9000:9000"
    environment:
      - AUTHENTIK_ROOT_URL=https://your-domain.com
      - AUTHENTIK_SECRET_KEY=your-secret-key
    volumes:
      - ./authentik.yml:/etc/authentik/authentik.yml

This configuration sets up Authentik with the latest version and maps port 9000 to your host machine. The authentik.yml file contains the configuration for Authentik, and the AUTHENTIK_ROOT_URL and AUTHENTIK_SECRET_KEY environment variables are used to configure Authentik.

Integrating Crowdsec

Finally, we’ll set up Crowdsec. Create a new file named crowdsec.yml and add the following configuration:

version: '3'
services:
  crowdsec:
    image: crowdsec/crowdsec:v1.4.2
    ports:
      - "8080:8080"
    volumes:
      - ./crowdsec.yml:/etc/crowdsec/crowdsec.yml
      - /var/run/docker.sock:/var/run/docker.sock

This configuration sets up Crowdsec with the latest version and maps port 8080 to your host machine. The crowdsec.yml file contains the configuration for Crowdsec, and the /var/run/docker.sock volume allows Crowdsec to communicate with Docker.

Putting It All Together

Now that we’ve set up Traefik, Authentik, and Crowdsec, it’s time to put them all together. Create a new file named docker-compose.yml and add the following configuration:

version: '3'
services:
  traefik:
    ...
  authentik:
    ...
  crowdsec:
    ...
  jellyfin:
    image: jellyfin/jellyfin:latest
    ports:
      - "8096:8096"
    environment:
      - JELLYFIN_PUBLISHED_SERVER_URL=https://your-domain.com
    depends_on:
      - traefik
      - authentik
      - crowdsec

This configuration sets up Jellyfin and depends on Traefik, Authentik, and Crowdsec. The JELLYFIN_PUBLISHED_SERVER_URL environment variable is used to configure Jellyfin to use the Traefik reverse proxy.

Conclusion

In this post, we’ve walked through the process of setting up Traefik, Authentik, and Crowdsec using Docker Compose. By following these steps, you can securely expose your favorite apps like Jellyfin or Nextcloud to the internet. Remember to replace the placeholders with your own values and to configure each tool according to your needs. With this setup, you’ll be well on your way to creating a robust security system for your self-hosted applications.

Uproszczanie Samoobsługowej Bezpieczeństwa: Przewodnik po Traefik, Authentik i Crowdsec

Zabezpieczanie Ulubionych Aplikacji Jak Jellyfin i Nextcloud za Pomocą Docker Compose

Jako ktoś, kto wszedł w świat samoobsługowego hostowania, spotkałem się z wieloma wyzwaniami. Jednym z największych przeszkód jest zabezpieczenie moich aplikacji. Spędziłem niezliczoną ilość godzin na poszukiwaniu idealnego rozwiązania, i to wtedy trafiłem na Traefik, Authentik i Crowdsec. Ale, jak wielu innych, miałem trudności z ich ustawieniem za pomocą Docker Compose, szczególnie z powodu braku aktualnych przewodników. W tym poście, opowiem o swojej wędrówce i dostarczę przewodnik krok po kroku, jak zabezpieczyć ulubione aplikacje jak Jellyfin lub Nextcloud za pomocą tych potężnych narzędzi.

Dlaczego Traefik, Authentik i Crowdsec?

Dlaczego wybrałem Traefik, Authentik i Crowdsec? Otóż, każde z tych narzędzi oferuje unikalny zestaw funkcji, które sprawiają, że są one idealne do samoobsługowego hostowania. Traefik jest serwerem proxy i balanserem obciążenia, który pozwala na udostępnienie aplikacji w internecie, jednocześnie zachowując ich bezpieczeństwo. Authentik to serwer uwierzytelniania, który umożliwia zarządzanie dostępem do aplikacji, a Crowdsec to narzędzie bezpieczeństwa, które pomaga chronić serwer przed złośliwą aktywnością. Łącząc te narzędzia, można stworzyć solidny system bezpieczeństwa, który zabezpiecza samoobsługowe aplikacje.

Konfiguracja Traefik z Docker Compose

Przed rozpoczęciem konfiguracji, upewnij się, że masz zainstalowany Docker i Docker Compose na swoim systemie. Następnie, utwórz nowy plik o nazwie docker-compose.yml i dodaj następującą konfigurację:

wersja: '3'
usługi:
  traefik:
    obraz: traefik:v2.5
    porty:
      - "80:80"
    woluminy:
      - ./traefik.yml:/etc/traefik/traefik.yml
      - ./acme.json:/etc/traefik/acme.json
      - /var/run/docker.sock:/var/run/docker.sock
    polecenie: --log.level=DEBUG
traefik.yml zawiera konfigurację dla Traefik, a plik acme.json przechowuje certyfikaty SSL. Wolumin /var/run/docker.sock pozwala Traefik na komunikację z Docker.

Konfiguracja Authentik

Następnie, ustawiamy Authentik. Utwórz nowy plik o nazwie authentik.yml i dodaj następującą konfigurację:

wersja: '3'
usługi:
  authentik:
    obraz: authentik/server:2022.10.1
    porty:
      - "9000:9000"
    środowisko:
      - AUTHENTIK_ROOT_URL=https://twoja-domena.com
      - AUTHENTIK_SECRET_KEY=twój-klucz-tajny
    woluminy:
      - ./authentik.yml:/etc/authentik/authentik.yml
authentik.yml zawiera konfigurację dla Authentik, a zmienne środowiskowe AUTHENTIK_ROOT_URL i AUTHENTIK_SECRET_KEY są używane do konfiguracji Authentik.

Integracja z Crowdsec

Na koniec, ustawiamy Crowdsec. Utwórz nowy plik o nazwie crowdsec.yml i dodaj następującą konfigurację:

wersja: '3'
usługi:
  crowdsec:
    obraz: crowdsec/crowdsec:v1.4.2
    porty:
      - "8080:8080"
    woluminy:
      - ./crowdsec.yml:/etc/crowdsec/crowdsec.yml
      - /var/run/docker.sock:/var/run/docker.sock
crowdsec.yml zawiera konfigurację dla Crowdsec, a wolumin /var/run/docker.sock pozwala Crowdsec na komunikację z Docker.

Łączenie wszystkiego

Teraz, gdy ustawiliśmy Traefik, Authentik i Crowdsec, czas połączyć je wszystkie. Utwórz nowy plik o nazwie docker-compose.yml i dodaj następującą konfigurację:

wersja: '3'
usługi:
  traefik:
    ...
  authentik:
    ...
  crowdsec:
    ...
  jellyfin:
    obraz: jellyfin/jellyfin:latest
    porty:
      - "8096:8096"
    środowisko:
      - JELLYFIN_PUBLISHED_SERVER_URL=https://twoja-domena.com
    zależności:
      - traefik
      - authentik
      - crowdsec
JELLYFIN_PUBLISHED_SERVER_URL jest używana do konfiguracji Jellyfin, aby używał serwera proxy Traefik.

Podsumowanie

W tym poście, przeszliśmy przez proces ustawiania Traefik, Authentik i Crowdsec za pomocą Docker Compose. Postępując zgodnie z tymi krokami, możesz zabezpieczyć ulubione aplikacje jak Jellyfin lub Nextcloud w internecie. Pamiętaj, aby zastąpić placeholder-y własnymi wartościami i skonfigurować każde narzędzie zgodnie z Twoimi potrzebami. Z tym ustawieniem, będziesz na dobrej drodze do stworzenia solidnego systemu bezpieczeństwa dla samoobsługowych aplikacji.

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Appliance - Powered by TurnKey Linux