The following caddyfile's rewrite directive is ignored in 0.10.0 (I reverted to 0.9.5 and confirmed it working):
api.example.com {
root /opt/example.com/latest/source
redir / /v1 307 {
if {path} is /
}
rewrite {
r ^/v1(.*)
to /api/{path}
}
gzip
proxy / [::1]:8000 {
transparent
except /static /robots.txt /favicon.ico
}
}
I can't figure it out. I can't get it to match at all, it's like it's being completely ignored. Tried a bunch of variations including a plain rewrite / /foo and it's just like it's commented out.
Download url, in case it's a plugin's fault (haven't tried on vanilla yet):
https://caddyserver.com/download/linux/amd64?plugins=http.awslambda,http.cors,http.expires,http.ratelimit,http.realip,tls.dns.cloudflare,tls.dns.gandi
Thanks @jleclanche -- but why did you not follow the issue template? 鈽癸笍 - we need all that information to help you. I need to be able to recreate your experiment and see exactly the same thing you're seeing; i.e. how do you know it's being ignored, and how can we know it too (all the tests are passing right now)?
Sorry, i tried to reduce the test case as much as possible. I'm still currently trying to reduce it further :). I'm using the systemd service file to run caddy (the one shipped with the tarball).
Thanks, it's helpful. :) How do you know rewrite is being ignored?
Okay, so my reduced set up so far: I have uwsgi serving a web page at exactly /api/v1/.
I have the following (literal) Caddyfile right now:
example.com:80 {
rewrite {
r ^/v1(.*)
to /api/{path}
}
proxy / [::1]:8000 {
transparent
}
}
If I send a HTTP HEAD Host: example.com /v1/ to Caddy, on 0.9.5, I receive a 200. On 0.10.0, I receive a 404 (uwsgi logs tells me I tried to query unmodified /v1/, which is a 404 on its own).
163e60a943f22b185b75e66ff70585f44cf872661a88a46740fe604b7a926ee7 caddy-0.10
bd06a3b76527244cf43e4b41ad3e3273604233f88da402ff31ba6dc92ff7b4ef caddy-0.9.5
Trying to remove plugins now.
Same thing with c17441e4719f7e4561774e273e1491600b0c776612bcd53f2f2b24e28f17befa caddy-0.10-vanilla.
I can confirm rewrite isn't being ignored:
ORIGINAL REQUEST: &{Method:GET URL:/v1/test ...}
REWRITTEN REQUEST: &{Method:GET URL:/api/v1/test ...}
So I think this must actually be https://github.com/mholt/caddy/pull/1584#issuecomment-296277579 - which is a tad tricky, and we're working on it!
(Edit, 6 hours later: Ignore any comment notifications you may have gotten from a user account that looked like mine earlier today.)
Let me start by saying (writing ...) I love caddy.
But I also had to revert to 0.9.5 to get rewrite with proxy working for me.