Set up Traefik V2 with grpc

Hi,

I’m trying to set up traefik v2 with grpc and met 404 page not found error. Then I tried to point to the dashboard itself and still get 404 page not found. I used the docker compose to build traefik and grpc server. I’m not sure if my config is not correct. Please help me, thank you.

global:
  sendAnonymousUsage: false
log:
  filePath: /dev/stdout
  level: DEBUG
accesslog:
  filepath: /dev/stdout
entrypoints:
  test:
    # Listen on port 8080 for incoming requests
    address: :8180
    forwardedHeaders:
      insecure: true
  dashboard:
    address: :80
api:
  dashboard: true
  debug: true
  entrypoint: dashboard
http:
  routers:
    routerTest:
      entrypoints:
      - test
      middlewares:
      - test-headers
      service: test
      rule: "Host(`127.0.0.1`)"
  middlewares:
    test-headers:
      headers:
        accessControlAllowMethods: [GET, PUT, DELETE, POST, OPTIONS]
        accessControlAllowOrigin: "*"
        accessControlAllowHeaders:
          - keep-alive
          - user-agent
          - cache-control
          - content-type
          - content-transfer-encoding
          - x-accept-content-transfer-encoding
          - x-accept-response-streaming
          - x-user-agent
          - x-grpc-web
          - grpc-timeout
          - authorization
        accessControlExposeHeaders:
          - grpc-status
          - grpc-message 
        accessControlMaxAge: 1728000
        addVaryHeader: true
  services:
    test:
      loadbalancer:
        servers:
        - url: "http://localhost"

Hello,

The YAML syntax will be supported in the next release (v2.0.0-alpha8).

For now, you must use the TOML syntax.

[global]
sendAnonymousUsage = false

[log]
filePath = "/dev/stdout"
level = "DEBUG"

[accesslog]
filepath = "/dev/stdout"

[entrypoints]

  [entrypoints.test]
  address = ":8180"
    [entrypoints.test.forwardedHeaders]
    insecure = true

  [entrypoints.dashboard]
  address = ":80"

[api]
dashboard = true
entrypoint = "dashboard"

[http]

  [http.routers]
    [http.routers.routerTest]
    entrypoints = ["test"]
    middlewares = ["test-headers"]
    service = "test"
    rule = "Host(`127.0.0.1`)"

  [http.middlewares]
    [http.middlewares.test-headers]
      [http.middlewares.test-headers.headers]
      accessControlAllowMethods = [
        "GET",
        "PUT",
        "DELETE",
        "POST",
        "OPTIONS"
      ]
      accessControlAllowOrigin = "*"
      accessControlAllowHeaders = [
        "keep-alive",
        "user-agent",
        "cache-control",
        "content-type",
        "content-transfer-encoding",
        "x-accept-content-transfer-encoding",
        "x-accept-response-streaming",
        "x-user-agent",
        "x-grpc-web",
        "grpc-timeout",
        "authorization"
      ]
      accessControlExposeHeaders = [
        "grpc-status",
        "grpc-message"
      ]
      accessControlMaxAge = 1728000
      addVaryHeader = true

  [http.services]
    [http.services.test]
      [http.services.test.loadbalancer]
        [[http.services.test.loadbalancer.servers]]
        url = "http://localhost"

If you want to do gRPC without HTTPS, you have to change the scheme of the server url:

      [http.services.test.loadbalancer]
        [[http.services.test.loadbalancer.servers]]
        url = "h2c://localhost"

Hi Idez,

I changed to TOML syntax, and still got the same error. Below are my files:

traefik.toml

[global]
sendAnonymousUsage = false

[log]
filePath = "/dev/stdout"
level = "DEBUG"

[accesslog]
filepath = "/dev/stdout"

[entrypoints]

  [entrypoints.test]
  address = ":8180"
    [entrypoints.test.forwardedHeaders]
    insecure = true

  [entrypoints.dashboard]
  address = ":80"

[api]
dashboard = true
entrypoint = "dashboard"

[http]

  [http.routers]
    [http.routers.routerTest]
    entrypoints = ["test"]
    middlewares = ["test-headers"]
    service = "test"
    rule = "Host(`127.0.0.1`)"

  [http.middlewares]
    [http.middlewares.test-headers]
      [http.middlewares.test-headers.headers]
      accessControlAllowMethods = [
        "GET",
        "PUT",
        "DELETE",
        "POST",
        "OPTIONS"
      ]
      accessControlAllowOrigin = "*"
      accessControlAllowHeaders = [
        "keep-alive",
        "user-agent",
        "cache-control",
        "content-type",
        "content-transfer-encoding",
        "x-accept-content-transfer-encoding",
        "x-accept-response-streaming",
        "x-user-agent",
        "x-grpc-web",
        "grpc-timeout",
        "authorization"
      ]
      accessControlExposeHeaders = [
        "grpc-status",
        "grpc-message"
      ]
      accessControlMaxAge = 1728000
      addVaryHeader = true

  [http.services]
    [http.services.test]
      [http.services.test.loadbalancer]
        [[http.services.test.loadbalancer.servers]]
        url = "h2c://test-grpc:8083"

docker-compose.yml

version: '3.1'

services:
  test-grpc:
    build:
      context: ./../
      dockerfile: ./Dockerfile
    image: test/app
    ports:
      - "8083:8083"
  test-traefik:
    build:
      context: ./../
      dockerfile: ./traefik/Dockerfile
    image: test/traefik
    ports:
      - "8180:8180"
      - "8089:80"
    links:
      - test-grpc

Dockerfile of traefik

FROM traefik:v2.0-alpine

COPY traefik/traefik.toml /etc/traefik/traefik.toml

When I call http://localhost:8089/api/rawdata in browser, it returns {}
I use grpc-web as client

I added

[providers]
  [providers.file]

seems it can recognize the route and http://localhost:8089/api/rawdata return data. However, there is another error from error logs:

level=debug msg="'500 Internal Server Error' caused by: stream error: stream ID 23; INTERNAL_ERROR"

The gRPC request is server stream