-
-
Save a-s-o/8419a5c94bc689c9b6823e8883b534a7 to your computer and use it in GitHub Desktop.
localhost:80 | |
gzip | |
ext .html | |
root /home/deploy/current/build/www | |
proxy /graphql localhost:3000 | |
rewrite /login { | |
to {path} /login | |
} | |
rewrite /app { | |
to {path} / | |
} | |
errors { | |
log caddy_error.log { | |
size 50 # Rotate after 50 MB | |
age 30 # Keep rotated files for 30 days | |
keep 5 # Keep at most 5 log files | |
} | |
404 404.html # Not Found | |
500 500.html # Internal Server Error | |
} |
Also, the more general version for rewrite to achieve the above can be done as follows:
rewrite {
r /([a-zA-Z]+)(.*)
to {path} {path}/ /{1}.html#{2}
}
Thank you to @captncraig and @abiosoft for help in Caddy chat
Suppose that reactjs spa app deploy to subfolder like /awesome .
After dozens of attempts, the rewrite
should like the following:
rewrite /awesome {
if {path} match /awesome
to {path} /awesome/
}
This may help if you need Caddy to always return index.html
for SPA routes:
rewrite {
to {file} index.html
}
Whenever I put one of these 'rewrite' directives in my Caddyfile I get an error:
run: adapting config using caddyfile: parsing caddyfile tokens for 'rewrite': ./bin/caddy/Caddyfile:9 - Error during parsing: Wrong argument count or unexpected line ending after 'rewrite'
I'm using Caddy 2 Beta 14, does the rewrite need to look different?
Hey Michael, this Caddyfile syntax belongs to Caddy v1. Caddy v2 has a bit different syntax, you can check it here: https://caddyserver.com/docs/caddyfile/directives/rewrite
Hey Michael, this Caddyfile syntax belongs to Caddy v1. Caddy v2 has a bit different syntax, you can check it here: https://caddyserver.com/docs/caddyfile/directives/rewrite
Hey RecuencoJones, can you please give me an example of the new Caddy v2 syntax for vue. I've tried so much but I just can't get it to work.
Sure! Please check: https://github.com/RecuencoJones/yamfe/blob/master/apps/navbar/Caddyfile
Thank you! It is easier than I thought
I would like the following routes, for example:
and everything else served normally; including
My current caddy file is above.
Thanks for the help