404 with Simple redirection

HI,
my first attempt ton redirect http request always fail to a 404 page.
i would like to redirect http://localhost:80/containers/json to http://server_ip:2375/containers/json

could you point out what is wrong in my configuration file?

## STATIC CONFIGURATION
log:
  level: DEBUG

api:
  insecure: true
  dashboard: true

entryPoints:
  web:
    address: ":80"

providers:
  file:
    filename: "traefik.yml"

## DYNAMIC CONFIGURATION
http:
  routers:
    route-to-local-ip:
      rule: "Path(`/containers/json`)"
      service: route-to-local-ip-service
      priority: 1000
      entryPoints:
        - web

  services:
    route-to-local-ip-service:
      loadBalancer:
        servers:
          - url: "http://server_ip:2375"

Please note that traefik.yml is usually static config, with providers.file you would load a different file (name) with dynamic config (routers, services). Use an absolute path to ensure to load the right file.

A "redirect" is a http response to tell the client/browser to visit a different address. You want Traefik to proxy/forward the request, correct?

Enable and check Traefik debug log (doc) during startup and request. Dynamic config file correctly loaded, router and service recognized?

Enable and check Traefik access log in JSON format (doc) during request. Is the right router used? Is http error status coming from target OriginStatus or Traefik itself?

Are you trying to build a Docker proxy? That can be solved with nginx (example).

1 Like

Hi,
Your are right,
it work if i split the config in 2 files.

traefik.yml:

## STATIC CONFIGURATION
log:
  level: DEBUG
entryPoints:
  web:
    address: ":80"
providers:
  file:
    filename: "/etc/traefik/traefik_dyn.yml"

traefik_dyn.yml:

## DYNAMIC CONFIGURATION
http:
  routers:
    centreon:
      rule: "Path(`/nodes`) || Path(`/info`) || Path(`/containers/json`)"
      service: docker_service
      priority: 1000
      entryPoints:
        - web

  services:
    docker_service:
      loadBalancer:
        servers:
          - url: "http://server_ip:2375"


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.