Skip to content

Traefik Dynamic Configuration Documentation

Overview

This documentation provides detailed information about the Traefik dynamic configuration for HTSV Systems services. Traefik is being used as a reverse proxy and load balancer to route traffic to various services within the infrastructure.

Table of Contents

  1. Installation
  2. Configuration Structure
  3. DNS Resolvers
  4. Middlewares
  5. HTTP Routers
  6. Services
  7. UDP Configuration
  8. Environment Information
  9. Troubleshooting
  10. docker-scratch

to provide access to promethus and grafana data dir

  • execute below commands
  • `sudo chown -R 1000:1000': sudo chown -R 1000:1000 /mnt/ubuntu-lv/containers/prometheus_data/
  • sudo chmod 755 /mnt/ubuntu-lv/containers
  • sudo chown -R 472:472 /mnt/ubuntu-lv/containers/grafana_data/

Att router Ports config

att router port config

reverseproxy

Installation

To set up the documentation site:

# Clone the repository
config credential.helper 'store --file ~/.git-credentials-trishtechAdmin'
git clone  https://github.com/trishtechadmin/product-shared-base-projects.git
cd working/traefik-docker
bash clean-start.sh

Configuration Structure

The Traefik dynamic configuration is organized into these main sections:

  • Resolvers: DNS resolvers for service discovery
  • HTTP: Contains middlewares, routers, and services definitions
  • Middlewares: Custom middleware configurations for security and functionality
  • Routers: URL-based routing rules to direct traffic to services
  • Services: Backend service definitions and load balancing configurations
  • UDP: Configuration for UDP-based services like VPN

DNS Resolvers

The configuration uses an internal DNS resolver for service discovery:

resolvers:
  internal-attdns:
    nameservers:
      - 192.168.1.54:53

This resolver allows Traefik to look up internal service names and route traffic accordingly.

Middlewares

Security Middlewares

Middleware Purpose Configuration
dashboard-auth Basic authentication for dashboard Uses credential file with header field support
secureHeaders HTTPS and security headers Enforces HTTPS with strict HSTS settings
compress Response compression Enables compression for all responses

Application-specific Middlewares

Middleware Purpose Configuration
nextcloud-headers Nextcloud security headers Sets SAMEORIGIN for frame options and XSS protection
nextcloud-regex URL rewriting for Nextcloud Redirects caldav/carddav requests to correct endpoint

HTTP Routers

Main Website

web:
  rule: "Host(`htsvsystems.com`)"
  service: htsvsystems-service
  entrypoints:
    - web
  middlewares:
     - https-redirect

web-secure:
  rule: "Host(`htsvsystems.com`)"
  entrypoints:
    - websecure
  tls:
    certResolver: letsencrypt
  service: htsvsystems-service

Development Environment Services

Router Hostname/url Backend Service TLS/Security Middlewares
Router Hostname/url Backend Service TLS/Security Middlewares
immich-https https://immich.htsvsystems.com immich-service LetsEncrypt -
nc-https https://nc.htsvsystems.com nc-service LetsEncrypt nextcloud-headers, nextcloud-regex
vault-https https://vault.htsvsystems.com vault-service LetsEncrypt -
localopen-webui-https https://open-webui.htsvsystems.com localopen-webui-service LetsEncrypt -
ldap-http https://ldap.htsvsystems.local.net ldap-local-service LetsEncrypt -
docs-lab-rhlab-https https://rhlab-docs.htsvsystems.com/ docs.apache-service LetsEncrypt -
vsfoodie-https https://vsfoodie.htsvsystems.com vsfoodie-service LetsEncrypt -
openapi-https https://openapi.htsvsystems.com openapi-service LetsEncrypt -
grafana-rhlab-https https://rhlab-grafana.htsvsystems.com grafana-rhlab-service LetsEncrypt -
proxy-rhlab-https https://rhlab-proxy.htsvsystems.com squid-proxy-rhlab-service LetsEncrypt -
jenkins-rhlab-https https://rhlab-jenkins.htsvsystems.com jenkins-rhlab-service LetsEncrypt -
api.htsvsystems.com https://api.htsvsystems.com jenkins-rhlab-service LetsEncrypt -
sso-api-rhlab-https https://sso-api.htsvsystems.com sso-api-rhlab-service LetsEncrypt -
wgeasy-ui-https https://openvpn-ui.htsvsystems.com wireguard-ui-service LetsEncrypt -
wgeasy-ui-https https://openvpn-ui.htsvsystems.com wireguard-ui-service LetsEncrypt -
traefik-rhlab-https https://traefik.htsvsystems.com traefik-service LetsEncrypt -
vsfoodie-https https://vsfoodie.htsvsystems.com vsfoodie-service LetsEncrypt -

Services

Rplex Saas Services

Service Type Server URL Notes
htsvsystems-service LoadBalancer http://rhlab-services-htsvsystems.com Main website
docs.htsvsystems-service LoadBalancer http://rhlab-kubeadmn:8081 Documentation service
rplex-docs.htsvsystems.com LoadBalancer https://rplex-docs.htsvsystems.com/docs Documentation service

Immich Services (with Load Balancing)

immich-service:
  weighted:
    healthCheck: { }
    services:
      - name: main
        weight: 3
      - name: backup
        weight: 1

main:
  loadBalancer:
    passHostHeader: true
    healthCheck:
      path: /api/server/ping
      interval: 10s
      timeout: 3s
    servers:
      - url: "http://qaappserver-api:2283/"

backup:
  loadBalancer:
    healthCheck:
      path: /api/server/ping
      interval: 10s
      timeout: 3s
    servers:
      - url: "http://api2-qaappserver:2283/"

The Immich service uses a weighted load balancing strategy with health checks, distributing traffic between main (75%) and backup (25%) servers.

Application Services hosted internally

Service Backend URL Published Port Additional Configuration
techdocs-service http://api2-qaappserver:8018/ 8018 Techdocs instance
nc-service https://qaappserver-api:8999 8999 Nextcloud instance
vault-service http://qaappserver-api:8000 8000 Vault secrets manager
ldap-local-service http://qaappserver-api:8081 8081 LDAP service
localopen-webui-service http://qaappserver-api:8818 8818 Open WebUI
vsfoodie-service https://qaappserver-api:1313 1313 VSFoodie application
openapi-service http://qaappserver-api:8818 8818 OpenAPI documentation
grafana-rhlab-service http://qaappserver-api:3000 3000 Grafana with login path
jenkins-rhlab-service https://qaappserver-api:8801 8801 Jenkins CI/CD
keycloak-sso-rhlab-service http://api2-qaappserver:8880 8880 Keycloak IDP
squid-proxy-rhlab-service http://api2-qaappserver:8001 8001 Squid proxy service
ittools-rhlab-service http://api2-qaappserver:8510 8510 ittools proxy service
drawio-rhlab-service http://api2-qaappserver:8540 8540 drawio service
kubenetes-dashboard https://rhlab-kubeadmn:31541/#/login 8540 kubernetes dashboard
traefik-microk8s-service https://rhlab-traefik.htsvsystems.local.net:31443/dashboard/ 8540 traefik microks deployment dashboard

UDP Configuration

The configuration includes UDP routing for VPN services:

udp:
  routers:
    openvpn-in:
      entrypoints:
        - "udpep"
      service: openvpn-service
    wireguard-in:
      entrypoints:
        - "udpep"
      service: wireguard-service
  services:
    openvpn-service:
      loadBalancer:
        servers:
        - address: "rhlab-kubeadm:4179"
    wireguard-service:
      loadBalancer:
        servers:
        - address: "rhlab-kubeadm:51820"

This enables routing for OpenVPN (port 4179) and WireGuard (port 51820) services.

Environment Information

Server Environments

Environment Purpose Primary Servers
Production Customer-facing services rhlab-services, qaappserver-api
QA/Testing Internal testing api2-qaappserver

Key Hostnames

  • Main Website: htsvsystems.com
  • Documentation: rhlab-docs.htsvsystems.com
  • Nextcloud: nc.htsvsystems.com
  • Vault: vault.htsvsystems.com
  • Immich: immich.htsvsystems.com
  • Grafana: rhlab-grafana.htsvsystems.com
  • Jenkins: rhlab-jenkins.htsvsystems.com
  • drawio: rhlab-drawio.htsvsystems.com
  • it-tools: rhlab-ittools.htsvsystems.com

Troubleshooting

Common Issues

  1. Certificate Issues
  2. Check LetsEncrypt resolver configuration
  3. Verify domain DNS settings
  4. Ensure ports 80/443 are accessible

  5. Service Unavailable

  6. Check service health checks
  7. Verify backend server is running
  8. Check network connectivity between Traefik and backend

  9. Middleware Errors

  10. Verify middleware configurations
  11. Check for syntax errors in middleware definitions
  12. Test middleware individually

Debugging

To enable debug logging in Traefik, add the following to your traefik.yml configuration:

log:
  level: DEBUG

docker-scratch

docker network create   --driver bridge   --subnet=172.20.0.0/16   --gateway=172.20.0.1   --opt com.docker.network.bridge.name=homelab-bridge   --opt com.docker.network.bridge.enable_icc=true   --opt com.docker.network.bridge.enable_ip_masquerade=true   homelab-external

docker network create   --driver bridge   --subnet 172.18.0.0/16   --gateway 172.18.0.1   homelab-external

docker network create \
--driver bridge \
--subnet 172.18.0.0/16 \
--gateway 172.18.0.1 \
homelab-internal

docker network ls 


cd   /mnt/ubuntu-lv/product-shared-base-projects/working/traefik-docker
bash clean-start.sh

tail -f /mnt/ubuntu-lv/containers/traefik-deploy/logs/traefik-out.log
dkpsa