Hi. Can someone explain why this isn’t working? I’ve tried with other placeholders and it seems work just fine but doesn’t with the {user} placeholder.
xxxx:81 {
proxy / localhost:7440 {
max_fails 1
}
browse
tls xxxx xxxx
basicauth / calisro xxx
basicauth / calisro2 xxx
rewrite {
if {user} not calisro
to /method_not_allowed
}
status 405 /method_not_allowed
log / stdout "{remote} - {user} [{when}] \"{method} {uri} {proto}\" {status} {size} - {rewrite_uri}"
}
Tests:
xxx@notebook2:~$ curl --head --user calisro:xxx https://xxxx:81/
HTTP/1.1 405 Method Not Allowed
Content-Type: text/plain; charset=utf-8
Server: Caddy
X-Content-Type-Options: nosniff
Date: Wed, 19 Dec 2018 19:34:05 GMT
Content-Length: 23
xxx@notebook2:~$ curl --head --user calisro2:xxx https://xxxx:81
HTTP/1.1 405 Method Not Allowed
Content-Type: text/plain; charset=utf-8
Server: Caddy
X-Content-Type-Options: nosniff
Date: Wed, 19 Dec 2018 19:34:14 GMT
Content-Length: 23
x.x.x.x - calisro [19/Dec/2018:14:34:05 -0500] "HEAD / HTTP/1.1" 405 23 - /method_not_allowed
x.x.x.x - calisro2 [19/Dec/2018:14:34:14 -0500] "HEAD / HTTP/1.1" 405 23 - /method_not_allowed
root@xxxx:/data/caddy# ./caddy --version
Caddy 0.11.1 (non-commercial use only)
If the rewrite is removed. It works just fine. Its not the proxied server: