Caddy 2.1 and not

1. Caddy version (caddy version):

2.1

2. How I run Caddy:

On Linux

a. System environment:

Ubuntu 18.04

b. Command:

        @postnotexist {
                not method GET
        }
        rewrite @postnotexist /404

c. Service/unit/compose file:

NA

d. My complete Caddyfile or JSON config:

NA

3. The problem I’m having:

To attempt POST e.g. at login page and post, not method GET should return /404?

4. Error messages and/or full log output:

NA

5. What I already tried:

Without the not is working fine that GET method will return /404

        @postnotexist {
                method GET
        }
        rewrite @postnotexist /404

6. Links to relevant resources:

NA

Works for me:

:8883

@notget not method GET
respond @notget "Nope"

respond "Hello"
$ curl -X GET http://localhost:8883
Hello

$ curl -X POST http://localhost:8883
Nope

You didn’t provide your entire config as requested by the thread template, so there’s not much else I can do to help. We need more info about your setup.

2 Likes

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