## The first two rewrites are as shown in examples
rewrite {
r /uploads\/(.*)\.php
to /
}
rewrite {
if {path} not_match ^\/wp-admin
to {path} {path}/ /index.php?{query}
}
# This rewrite is the one I am attempting to add
rewrite {
if_op or
if {path} not_match ^\/csi-evp
if {path} not_match ^\/contact-us
to /index.php
}
I need the site to stay up at all costs, so I attempt to reload the dockerized caddy with (is this correct?):
docker exec -it <caddy-container> kill -s USR1 1
What I want to do is navigate to home page on any url that is not either of those two but only if the first two rewrite rules didn’t already work.
Part of the problem is that I understood (seemingly incorrectly) that I could make a change from the host and the container would have access to that change. This does not seem to be the case, so my debugging has been completely off.
Yeah… if nothing is working, something is very wrong. At a glance, all your rewrites look functional.
It… might be? This assumes that Caddy is running as PID 1, but it should probably work. I don’t think you need an interactive tty, though.
Personally, I use: docker exec <CONTAINER> pkill -SIGUSR1 caddy
I’ve had this issue before - for example in vim, the editor does not actually write to the file in question but instead saves the buffer to a new file and swaps it in place. A lot of code editors seem to use this method as well.
The issue here is that for a Docker volume mount, all the container’s files are referred to by inode. When you swap a file in-place, you’re replacing one inode with another - so you never actually edit the file, you just delete the one outside the container and replace it with a new one - breaking the volume mount for that file (the one inside the container keeps using the file at the previous inode).
You can fix this by disabling atomic saving (or whatever the feature is called in your editor) - for example, in vim this is done with set backupcopy=yes, which tells the editor to save the contents of the original to a copy instead of saving the buffer and then writes directly to the original file (so no swapping/inode changes are required).