Remote_ip validates as "unrecognized subdirective"

1. Caddy version (caddy version):

v2.4.5

2. How I run Caddy:

Running in a docker container.
Used the following image using latest tag: Docker Hub

a. System environment:

Ubuntu 20.04.3 LTS host
Docker version: 20.10.8

b. Command:

N/A

c. Service/unit/compose file:

N/A

d. My complete Caddyfile or JSON config:

uptime.itss.com.au {
        reverse_proxy localhost:3001 {
                remote_ip 122.230.17.30/32
        }
}

3. The problem I’m having:

When I run sudo caddy validate I get the below error message and it doesn’t restrict to my IP address:

validate: adapting config using caddyfile: parsing caddyfile tokens for ‘reverse_proxy’: Caddyfile:9 - Error during parsing: unrecognized subdirective remote_ip

4. Error messages and/or full log output:

validate: adapting config using caddyfile: parsing caddyfile tokens for ‘reverse_proxy’: Caddyfile:9 - Error during parsing: unrecognized subdirective remote_ip

5. What I already tried:

  1. Tried reformatting with sudo caddy fmt
  2. Tried to use remote_addr instead as I found that on some caddy forum posts

6. Links to relevant resources:

1 Like

Request matchers don’t go within other handler directives.

Read the top of the Request Matchers docs, you need to define a named matcher which you’ll then apply to reverse_proxy.

3 Likes

Aha! Thank you!

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