Hiding dotfiles?

Hi guys,

Following on from twitter, I’m planning to host a Voidlinux distribution mirror behind Caddy. I noticed with the rsync that I run, tmp files show.

Googling I found an old bug I created https://github.com/mholt/caddy/issues/458#issuecomment-189753794 but the solution results in 2018/09/30 13:49:42 Caddyfile:7 - Error during parsing: Wrong argument count or unexpected line ending after 'status'.

888.dabase.com:2015 {
        tls off
        root /mnt/mirror
        browse
        rewrite {
                if {file} starts_with .
                        status 404
        }
}

So any tips here please? Thank you in advance!

p.s. i noticed that dir listing are quite slow. Any tips here for caching or boosting browse performance?

Hi @hendry,

I don’t know if that fix ever worked, because I don’t recall a time when rewrite ever supported a status subdirective.

You’ll need to use status outside of that directive, rewriting to something specific that you can then set the status on, like so:

rewrite {
  if {file} starts_with .
  to /status_404_dotfile
}
status 404 /status_404_dotfile

In the above, /status_404_dotfile can be replaced with any sufficiently unique URL that wont clash with a real request.

https://caddyserver.com/docs/rewrite
https://caddyserver.com/docs/status

It did for a few versions - a short time - before we decided to move it outside to its own directive. It’s better this way for sure.

1 Like

Is it related to these?
https://github.com/mholt/caddy/issues/2131
https://github.com/mholt/caddy/pull/2133

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.