Skip to main content

Traefik

Labels

Provider: Docker

  1. traefik.enable=true: Enables Traefik for the service. This label is necessary for Traefik to consider this container as part of its routing configuration.

  2. traefik.docker.network=public_network: Specifies the Docker network that Traefik should use for connections to this service. It's important for network routing.

  3. traefik.http.routers.codechat_api_v2.rule=Host(apiv2.domain.dev): Defines a rule for the router. In this case, it routes requests to apiv2.domain.dev to this service.

  4. traefik.http.routers.codechat_api_v2.entrypoints=websecure: Assigns the router to the websecure entrypoint, usually indicating HTTPS traffic.

  5. traefik.http.routers.codechat_api_v2.priority=1: Sets the priority of the router. Routers with higher priority values are evaluated first.

  6. traefik.http.routers.codechat_api_v2.tls.certresolver=letsencryptresolver: Specifies the certificate resolver to use for TLS. Here, it's using Let's Encrypt.

  7. traefik.http.routers.codechat_api_v2.service=codechat_api_v2: Links the router to the codechat_api_v2 service.

  8. traefik.http.routers.codechat_api_v2.middlewares=corsHeader@docker: Associates the corsHeader middleware with this router.

  9. traefik.http.services.codechat_api_v2.loadbalancer.server.port=8083: Specifies the port on which the service is running. Traefik will forward traffic to this port.

  10. traefik.http.services.codechat_api_v2.loadbalancer.passhostheader=true: Instructs the load balancer to pass the host header to the backend service.

  11. traefik.http.middlewares.corsHeader.headers.accessControlAllowMethods=GET,PUT,POST,DELETE,PATCH: Sets allowed methods for Cross-Origin Resource Sharing (CORS).

  12. traefik.http.middlewares.corsHeader.headers.accessControlAllowHeaders=*: Allows all headers for CORS.

  13. traefik.http.middlewares.corsHeader.headers.accessControlAllowOriginList=*: Allows all origins for CORS.

  • traefik.http.middlewares.corsHeader.headers.accessControlAllowOriginList=https://docs.codechat.dev,https://frontend.domain.com
  1. traefik.http.middlewares.corsHeader.headers.accessControlMaxAge=100: Sets the max age for CORS preflight requests.

  2. traefik.http.middlewares.corsHeader.headers.addVaryHeader=true: Indicates whether to add a Vary header when CORS is enabled.

  3. traefik.http.middlewares.corsHeader.headers.customrequestheaders.X-Forwarded-Proto=https: Adds a custom request header, in this case, setting X-Forwarded-Proto to https.

  4. traefik.http.routers.codechat_api_v2.middlewares=sslheader@docker: Associates another middleware named sslheader with the codechat_api_v2 router.