file_server 語法:
file_server [<matcher>] [browse] { root <path> hide <files...> index <filenames...> browse [<template_file>] precompressed <formats...> status <status> disable_canonical_uris pass_thru }
隱藏單個文件:
your_host { root * /xx/project_path encode gzip file_server { hide .gitignore } }
隱藏文件夾及其里面內容:
your_host { root * /xx/project_path encode gzip file_server { hide .git .git/ .git/* .git* .gitignore } }
注意:hide 指定如果不加絕對路徑,那么就是相對於 root 位置的路徑。
Tool:RESTClient
Refer:Caddy2 file_server 用法
Refer:https://caddyserver.com/docs/caddyfile/directives/file_server

