Health Check Not Using Backend API Docker Hostname

Hi,

I am very new to using Traefik and just want to set it up so I can enable https and use health checks to ensure the API services are healthy before proceeding with the request.

Currently, no matter what I do, the health checks fail because it tries calling the health endpoint without the proper hostname.

It calls: https:///api/api/health?type=ready

When it should call: http://api:3000/health?type=ready

The only thing that has worked is if I set the path to the full url, rather than just give it a path. Like this:

services:

    api-service:

        loadBalancer:

            servers:

                - url: 'http://api:3000'

            healthCheck:

                path: https://\[domain\].com/api/health?type=ready

                interval: '5s'

                timeout: '2s'

I don’t know why this is happening. The only reason I can think of is if it is because my .NET API enables UseHttpsRedirection.

Does anyone know how I can fix this? Thanks.

LMAO, JFC. Nevermind. It indeed was due to UseHttpsRedirection. Should have tried it first.