basickarl
basickarl

Reputation: 40561

Simple Traefik reverse proxy configuration

I'm starting up Traefik version 2.1.4 with the following configuration:

defaultEntryPoints:
  - http

entryPoints:
  hole-1:
    address: ':663'

frontends:
  hole-frontend-1:
    backend: hole-backend-1
    entrypoints:
      - hole-1

backends:
  hole-backend-1:
    servers:
      hole-server-1:
        url: 'http://11.23.24.1:3000'
        weight: 10

When I hit the http://11.23.24.1:663 I'm hit with the Traefik page 404 pages not found. When I go to http://11.23.24.1:3000 in the browser, it works, it displays the page.

I can't seem to figure out how to set up a reverse proxy in Traefik to point http://11.23.24.1:663 to http://11.23.24.1:3000.

I tried this, but I get the error

2020/02/18 11:39:43 command traefik.exe error: no valid configuration found in file: C:\config\traefik.yaml

http:
  routers:
    hole-router-1:
      rule: "Host(`11.23.24.1`) && PathPrefix(`/`)"
      service: hole-service

services:
  hole-service:
    loadBalancer:
      servers:
        - url: http://11.23.24.1:3000

Upvotes: 1

Views: 3259

Answers (2)

basickarl
basickarl

Reputation: 40561

C:\config\traefik\traefik.yaml:

entryPoints:
  hole-1:
    address: ":661"

providers:
  file:
    filename: C:\config\traefik\dynamic.yaml

C:\config\traefik\dynamic.yaml:

http:
  routers:
    hole-router-1:
      rule: "Path(`/`)"
      entryPoints:
        - hole-1
      service: hole-service

  services:
    hole-service:
      loadBalancer:
        servers:
          - url: http://10.23.24.10:3000

I started Traefik with: traefik.exe --configFile=C:/config/traefik/traefik.yaml

Upvotes: 1

Al-waleed Shihadeh
Al-waleed Shihadeh

Reputation: 2855

Traefik 2.1 do not support frontend and backends any more. This repository provides some examples to deploy Traefik 2.1 https://github.com/wshihadeh/traefik_v2

Example to do it with Docker:

version: '3.7'

networks:
  traefik:
    external: true

volumes:
  db_data:

services:

  proxy:
    image: traefik:v2.1
    command:
      - '--providers.docker=true'
      - '--entryPoints.http.address=:80'
      - '--providers.providersThrottleDuration=2s'
      - '--providers.docker.watch=true'
      - '--providers.docker.exposedbydefault=false'
      - '--providers.docker.defaultRule=Host("local.me")'
      - '--accessLog.bufferingSize=0'
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock:ro'
    ports:
      - '663:80'
    deploy:
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      update_config:
        delay: 10s
        order: start-first
        parallelism: 1
      rollback_config:
        parallelism: 0
        order: stop-first
    logging:
      driver: json-file
      options:
        'max-size': '10m'
        'max-file': '5'
    networks:
      - traefik

   hole-backend:
    image:  hole-backend:demo-v1
    command: 'web'
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.services.hole.loadbalancer.server.port=8080
        - traefik.http.routers.hole.rule=Host(`hole.local.me`)
        - traefik.http.routers.hole.service=blog
        - traefik.http.routers.hole.entrypoints=web
        - traefik.docker.network=traefik
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      update_config:
        delay: 10s
        order: start-first
        parallelism: 1
      rollback_config:
        parallelism: 0
        order: stop-first
    logging:
      driver: json-file
      options:
        'max-size': '10m'
        'max-file': '5'
    networks:
      - traefik

Upvotes: 0

Related Questions