1. Caddy version (caddy version
):
v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=
2. How I run Caddy:
a. System environment:
Docker
(strip-www) {
@www.{args.0} host www.{args.0}
redir @www.{args.0} https://{args.0}{uri}
}
(common-tls-example) {
tls let_admin@example.com
# HSTS (63072000 seconds)
header Strict-Transport-Security "max-age=63072000"
}
www.example.com:443 {
import strip-www example.com
import common-tls-example
}
example.com:443 {
reverse_proxy http://internal_app:65
import common-tls-example
}
I am serving an application (internal_app
) at https://example.com/
I didn’t write this application and the page at https://example.com/should-be-inaccessible/?dm=this-doesnt-matter should be inaccessible to the user (and return a 404 or 302 to /). There are 2 ways I can think of this path being created:
- accessed by the user (saved bookmark or history etc)
- generated by the application (eg: if user logs out, under certain scenarios, the app sends them to this page)
This is an update/fix that should be made in the application but until that’s done, I want to work around it. Is this possible through caddyfile?
I was reading the docs and I think it should be using the path matcher:
… but I am struggling to write the path matcher stanza.
- Is there a way to redir to / in case of 1 or 2?
- If not, atleast return a 404?