Caddy will respond with a 401 when it wants to tell the client “hey I need you to authenticate”, so if you redirect or proxy when that happens, then the browser will never get asked to authenticate.
Because the 401 is what actually triggers the browser to ask. That’s how Basic Auth works, and has always worked. That’s not a Caddy thing, it’s just how it works.
I’m not really clear on what your goal is here. What are you trying to do with handle_errors exactly?
sorry for my english, maybe I was not clear…
I’m trying to customize the 401 error page, so I put a basicauth for authenticate, and if I put wrong credential, it give me 401 (custom) error page.
the thing is that if my line has rewrite... the error page appear before that Caddy ask me credential.
If my line has respond works correctly, the error page appear only if I put wrong credential.
in this case the browser doens’t prompt me for a username and password:
Oh I think what’s going on is reverse_proxy changes the written status code, whereas respond keeps the same status code, I think. (I don’t have time to test right now to confirm though).
To make reverse_proxy keep the status code, you can do this (you’ll need v2.5.0-rc.1 though cause we made a slight syntax change):
run: adapting config using caddyfile: parsing caddyfile tokens for 'handle_errors': /etc/caddy/Caddyfile:41 - Error during parsing: parsing caddyfile tokens for 'reverse_proxy': /etc/caddy/Caddyfile:39 - Error during parsing: must have two arguments: a response matcher and a status code
run: adapting config using caddyfile: parsing caddyfile tokens for 'handle_errors': /etc/caddy/Caddyfile:43 - Error during parsing: parsing caddyfile tokens for 'reverse_proxy': /etc/caddy/Caddyfile:41 - Error during parsing: bad integer value '{http.error.status_code}': strconv.Atoi: parsing "{http.error.status_code}": invalid syntax