1. Caddy version (caddy version
):
2.4.6
2. How I run Caddy:
I run Caddy with the Docker image:
FROM klakegg/hugo:0.74.3-alpine AS hugo
COPY blog /src
RUN hugo
FROM caddy:2-alpine
COPY Caddyfile /etc/caddy/Caddyfile
COPY static /site
COPY --from=hugo /src/public /site/blog
a. System environment:
Docker
b. Command:
Default Docker RUN command.
c. Service/unit/compose file:
Deployed on GCP Cloud Run.
gcloud run deploy "$SERVICE_NAME" \
--quiet \
--region "$RUN_REGION" \
--image "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" \
--platform "managed" \
--allow-unauthenticated
d. My complete Caddyfile or JSON config:
{
email julianvmodesto@gmail.com
http_port {$PORT}
auto_https off
}
:{$PORT} {
root * /site
file_server
try_files {path} {path}/
rewrite /now /blog/now
encode zstd gzip
log {
output stdout
}
header Cache-Control max-age=3600
header {
# disable clients from sniffing the media type
X-Content-Type-Options nosniff
# clickjacking protection
X-Frame-Options DENY
# keep referrer data off of HTTP connections
Referrer-Policy no-referrer-when-downgrade
}
@redir_hosts {
host julianvmodesto.dev www.julianvmodesto.dev julianmodesto.com www.julianmodesto.com julianvmodesto.com
}
redir @redir_hosts https://www.julianvmodesto.com{uri}
}
:8888 {
respond / 200
log {
output discard
}
}
3. The problem I’m having:
I’m attempting to redirect https://www.julianvmodesto/now internally to /site/blog/now/index.html.
4. Error messages and/or full log output:
None.
5. What I already tried:
I’ve tried reordering my rewrite directive higher up and lower down, and I’ve also tried using the handle
directive to serve exactly the file /site/blog/now/index.html
or /blog/now/index.html
.
6. Links to relevant resources:
None.