Docker and Traefik issues

My origianl config:

services:
  web:
    restart: 'always'
    stdin_open: true
    tty: true
    logging:
      options:
        max-file: '5'
        max-size: '10m'
    build:
      context: '../../../'
      dockerfile: '.wappler/targets/DigitalOcean/web/Dockerfile'
    labels:
      - 'traefik.enable=true'
      - 'traefik.docker.network=wappler-compose_proxy'
      - 'traefik.http.routers.some-name__digitalocean_web.entrypoints=web'
      - 'traefik.http.routers.some-name__digitalocean_web.rule=Host(`some-domain.com`)'
      - 'traefik.http.routers.some-name__digitalocean_web-secure.entrypoints=websecure'
      - 'traefik.http.routers.some-name__digitalocean_web-secure.rule=Host(`some-domain.com`)'
      - 'traefik.http.routers.some-name__digitalocean_web-secure.tls=true'
      - 'traefik.http.routers.some-name__digitalocean_web-secure.tls.certresolver=leresolver'
      - 'traefik.http.services.some-name__digitalocean_web.loadbalancer.server.port=3000'
      - 'traefik.http.routers.some-name__digitalocean_www_web-secure.entrypoints=websecure'
      - 'traefik.http.routers.some-name__digitalocean_www_web-secure.rule=Host(`www.some-domain.com`)'
      - 'traefik.http.routers.some-name__digitalocean_www_web-secure.tls=true'
      - 'traefik.http.routers.some-name__digitalocean_www_web-secure.tls.certresolver=leresolver'
      - 'traefik.http.middlewares.some-name__digitalocean_www-redirect.redirectregex.regex=^https://www.some-domain.com/(.*)'
      - 'traefik.http.middlewares.some-name__digitalocean_www-redirect.redirectregex.replacement=https://some-domain.com/$${1}'
      - 'traefik.http.middlewares.some-name__digitalocean_www-redirect.redirectregex.permanent=true'
      - 'traefik.http.routers.some-name__digitalocean_www_web-secure.middlewares=some-name__digitalocean_www-redirect'
    networks:
      proxy: ~
    volumes:
      - 'user_uploads:/opt/node_app/public/temp_uploads:rw'
volumes:
  user_uploads: ~
networks:
  proxy:
    name: 'wappler-compose_proxy'
    external: true

Working config (with above Docker rollback):

services:
  traefik:
    image: traefik:v2.0
    restart: always
    ports:
      - "8081:80"    # Remap HTTP to port 8080 (instead of 80)
      - "8443:443"   # Remap HTTPS to port 8443 (instead of 443)
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"  # Enable Traefik to interact with Docker
    networks:
      - wappler-compose_proxy  # Ensure Traefik is on the same network as the other services
    command:
      - "--api.insecure=true"
      - "--entryPoints.web.address=:80"         # Web entry point for HTTP
      - "--entryPoints.websecure.address=:443"  # WebSecure entry point for HTTPS
      - "--providers.docker=true"  # Enable Docker provider for Traefik to discover services
      - "--certificatesresolvers.leresolver.acme.httpChallenge.entryPoint=web"  # Let's Encrypt HTTP-01 challenge
      - "--certificatesresolvers.leresolver.acme.email=your-email@example.com"  # Add your email for Let's Encrypt
      - "--certificatesresolvers.leresolver.acme.storage=/etc/traefik/acme.json"  # ACME certificate storage

  web:
    restart: 'always'
    stdin_open: true
    tty: true
    logging:
      options:
        max-file: '5'
        max-size: '10m'
    build:
      context: '../../../'
      dockerfile: '.wappler/targets/DigitalOcean/web/Dockerfile'
    labels:
      - 'traefik.enable=true'
      - 'traefik.docker.network=wappler-compose_proxy'  # Ensure this matches the network name
      - 'traefik.http.routers.some-name__digitalocean_web.entrypoints=web'  # HTTP entry point (port 80)
      - 'traefik.http.routers.some-name__digitalocean_web.rule=Host(`some-domain.com`)'  # Host rule for the domain
      - 'traefik.http.routers.some-name__digitalocean_web-secure.entrypoints=websecure'  # HTTPS entry point (port 443)
      - 'traefik.http.routers.some-name__digitalocean_web-secure.rule=Host(`some-domain.com`)'  # HTTPS rule for the domain
      - 'traefik.http.routers.some-name__digitalocean_web-secure.tls=true'  # Enable TLS for HTTPS
      - 'traefik.http.routers.some-name__digitalocean_web-secure.tls.certresolver=leresolver'  # Use the Let's Encrypt certificate resolver
      - 'traefik.http.services.some-name__digitalocean_web.loadbalancer.server.port=3000'  # Port of the service inside the container
      - 'traefik.http.routers.some-name__digitalocean_www_web-secure.entrypoints=websecure'  # HTTPS for www subdomain
      - 'traefik.http.routers.some-name__digitalocean_www_web-secure.rule=Host(`www.some-domain.com`)'  # Rule for www subdomain
      - 'traefik.http.routers.some-name__digitalocean_www_web-secure.tls=true'  # TLS for www subdomain
      - 'traefik.http.routers.some-name__digitalocean_www_web-secure.tls.certresolver=leresolver'  # TLS certresolver
      - 'traefik.http.middlewares.some-name__digitalocean_www-redirect.redirectregex.regex=^https://www.some-domain.com/(.*)'  # Redirect www to non-www
      - 'traefik.http.middlewares.some-name__digitalocean_www-redirect.redirectregex.replacement=https://some-domain.com/$${1}'  # Replace www with non-www
      - 'traefik.http.middlewares.some-name__digitalocean_www-redirect.redirectregex.permanent=true'  # Permanent redirect
      - 'traefik.http.routers.some-name__digitalocean_www_web-secure.middlewares=some-name__digitalocean_www-redirect'  # Apply redirect middleware
    networks:
      - wappler-compose_proxy  # Ensure the web service is on the same network as Traefik
    volumes:
      - 'user_uploads:/opt/node_app/public/temp_uploads:rw'  # Handle file uploads for the app

volumes:
  user_uploads: ~  # Define the user uploads volume

networks:
  wappler-compose_proxy:
    external: true  # Make sure the proxy network exists or create it manually
1 Like