Hello! I need to check request header (content-type) if it “application/json” to do reverse proxy if not respond 404. I need users who use the browser at /api/* to see the 404 error, now they see my API
My current caddyfile:
example.com
log
encode gzip
root * /usr/share/caddy
handle /api/* {
reverse_proxy django:8000
}
handle /admin/* {
reverse_proxy django:8000
}
handle {
try_files {path} /index.html
file_server browse
}
I need something like this:
example.com
log
encode gzip
root * /usr/share/caddy
@contenttype {
header Content-Type application/json
}
handle @contenttype {
respond "Access denied" 404 {
close
}
}
handle /api/* {
reverse_proxy django:8000
}
handle /admin/* {
reverse_proxy django:8000
}
handle {
try_files {path} /index.html
file_server browse
}
Backend: Django + API + caddy + SPA(frontend).