Gateway API 421 errors

Hello,

Thank you for Traefik, I have been using it for several years in a more or less advanced way and it works really well :+1:

I search if it's possible to proxy a request to an another service (not mine) with add key on header.

An example:

  • https://my-web-app.blabla.org call my gateway api https://my-api.blabla.org/api/v1/blabla with CORS
  • https://my-api.blabla.org/api/v1/blabla is intercepted by Traefik to add a header and redirect the request to provider API
  • Web app can access to api data without know the API key

Actually I have a 421 errors:

Misdirected Request

The client needs a new connection for this request as the requested host name does not match the Server Name Indication (SNI) in use for this connection.

I have this configuration:

http:
  routers:
    gateway_api_blabla_org:
      rule: Host(`gateway.api.blabla.org`)
      entryPoints:
        - websecure
      service: api_gateway
      middlewares:
        - api_gateway_header
      tls:
        certResolver: letsencrypt
  services:
    api_gateway:
      loadBalancer:
          servers:
            - url: https://gateway.api.provider.fr
  middlewares:
    api_gateway_header:
      headers:
          customRequestHeaders:
            api_key: "abcdef12345"

If you have any idea how to solve this please let me know :wink:

Is this an error status from Traefik or from your target service? Enable and check Traefik access log in JSON format (Origin/Downstream).