How to fix caddy's status code out of tolerances for reverse proxy?

1. Caddy version (caddy version):

2.4.3-alpine

2. How I run Caddy:

podman-compose with docker-compose.yaml

a. System environment:

Debian 11, podman, podman-compose

b. Command:

podman-compose up

c. Service/unit/compose file:

version: "3.7"
services:
  node-app1:
    image: node-app:latest
    container_name: node-app1
    restart: unless-stopped
    environment:
      - NODE_ENV=production
      - PORT=8000
      - APP_NO=node-app1
  node-app2:
    image: node-app:latest
    container_name: node-app2
    restart: unless-stopped
    environment:
      - NODE_ENV=production
      - PORT=8080
      - APP_NO=node-app2
  caddy:
    image: docker.io/caddy/caddy:alpine
    container_name: caddy-service
    restart: unless-stopped
    ports:
      - 8000:80
      - 8080:443
    volumes:
      - ${PWD}/Caddyfile:/etc/caddy/Caddyfile
    depends_on:
      - node-app1
      - node-app2

d. My complete Caddyfile or JSON config:

:2021

encode gzip zstd

reverse_proxy node-app1:8000 node-app2:8080 {
  lb_policy random_choose 2
}

3. The problem I’m having:

Can’t reach API and Caddy logs status code out of tolerances for reverse proxy.

4. Error messages and/or full log output:

...
{"level":"info","ts":1626890003.6812198,"logger":"http.handlers.reverse_proxy.health_checker.active","msg":"status code out of tolerances","status_code":404,"host":"node-app1:8000"}
{"level":"info","ts":1626890003.6812427,"logger":"http.handlers.reverse_proxy.health_checker.active","msg":"status code out of tolerances","status_code":404,"host":"node-app2:8080"}
...

5. What I already tried:

Tried running API container alone and it runs successfully.

6. Links to relevant resources:

On SO: node.js - How to fix caddy's status code out of tolerances for reverse proxy? - Stack Overflow

I’m confused, because your config doesn’t enable the active health checks.

Are you sure that’s all that’s in your config?

Also, your docker-compose.yml seems mismatched with your Caddyfile, since it maps ports 80 and 443 to 8000 and 8080, but your Caddyfile is serving on port 2021.

This topic was automatically closed after 30 days. New replies are no longer allowed.