Traefik Configuration and Environment Setup

Overview

This document covers combining Traefik dynamic configurations for different services under same network, forwarding requests to separate Raspberry Pi instances, and setting up an application environment on a specific port.

Traefik Dynamic Configuration

The configurations detail how to access the Traefik dashboard on one Raspberry Pi and set up forwarding rules to other Raspberry Pi instances. Here’s an example for accessing two different domains:

http:
  middlewares:
    redirect-to-https:
      redirectscheme:
        scheme: https
    gzip:
      compress: true
    auth:
      basicAuth:
        users:
          - 'admin:password'
  routers:
    dashboard:
      rule: 'Host(`<traefik-dashboard-domain>`) && (PathPrefix(`/dashboard`) || PathPrefix(`/api`))'
      service: api@internal
      middlewares:
        - auth
    rp2-https:
      middlewares:
        - gzip
      service: lb-https
      tls:
        certResolver: letsencrypt
      rule: Host(`traefik-for-raspberrypi-two-dashboard-domain>`)
    media-https:
      middlewares:
        - gzip
      service: media-https
      tls:
        certResolver: letsencrypt
      rule: Host(`service-domain>`)
  services:
    lb-https:
      loadBalancer:
        servers:
          -
            url: 'http://192.168.1.5:80' # Internal IP where reverse proxy is listening to
    media-https:
      loadBalancer:
        servers:
          -
            url: 'http://192.168.1.5:8096' # Internal IP where the docker service port is exposed