1. Output of caddy version
:
v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=
2. How I run Caddy:
I run Caddy using Google Cloud Run to serve my Docker image which uses the official Caddy Docker image as its parent image.
a. System environment:
Google Cloud Run.
b. Command:
N/A
c. Service/unit/compose file:
FROM caddy
COPY website/Caddyfile /etc/caddy/Caddyfile
COPY website/public /srv
d. My complete Caddy config:
{
auto_https off
}
:{$PORT} {
root * /srv
encode gzip
file_server
handle_errors {
rewrite * /{err.status_code}.html
file_server
}
header / {
-Server
Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
X-XSS-Protection "1; mode=block"
X-Frame-Options "DENY"
X-Content-Type-Options "nosniff"
Referrer-Policy "strict-origin-when-cross-origin"
Permissions-Policy "fullscreen=(self)"
cache-control "max-age=0,no-cache,no-store,must-revalidate"
}
@static {
path_regexp \.(ico|css|js|gif|jpg|jpeg|png|svg|woff)$
}
header @static Cache-Control max-age=604800
@plausible path /js/script.js /api/event
handle @plausible {
rewrite /js/script.js /js/script.js
reverse_proxy https://plausible.io {
header_up Host {http.reverse_proxy.upstream.hostport}
}
}
}
3. The problem I’m having:
How do I rewrite the request URL so that a .html
extension is added if not already present?
4. Error messages and/or full log output:
N/A