当我 root 特定目录时,Caddy 文件服务器浏览不工作
这是我的 Caddyfile
:
aruiplex.com {
encode gzip
file_server /files/* {
root /files
browse
}
reverse_proxy /api/* localhost:7022
file_server {
root /srv
}
}
这是我的计划:
当请求 URL 为
aruiplex.com
时,Caddy 可以向我显示index.html
在/srv
目录中。当请求 URL 为
aruiplex.com/files
时,Caddy 可以显示 docker 容器中/files
目录中的文件列表。当请求 URL 为
aruiplex.com/api
时,Caddy 可以将此请求传递给localhost:7022
。
但是当我请求 aruiplex.com/files 文件服务器不工作时,它给了我一个 404。我已经检查了 docker 容器中的这个目录,有一些文件。
这是我的文件树,位于 docker 容器中的 /
处:
/
/home
/etc
/...
/files
/aaa.txt
/bbb.txt
/srv
/index.html
版本:Docker 中的 Caddy 2.4.6。
PS:如果您在 caddy.community 上看到该帖子,也是我。
Here is my Caddyfile
:
aruiplex.com {
encode gzip
file_server /files/* {
root /files
browse
}
reverse_proxy /api/* localhost:7022
file_server {
root /srv
}
}
Here is my plan:
When request URL is
aruiplex.com
, Caddy can show me theindex.html
in/srv
directory.When request URL is
aruiplex.com/files
, Caddy can show me the file list in the/files
directory in docker container.When request URL is
aruiplex.com/api
, Caddy can pass this request tolocalhost:7022
.
But when I request aruiplex.com/files
file server is not working, it gives me a 404. And I have check this directory in docker container, there have some files.
Here is my file tree at /
in docker container:
/
/home
/etc
/...
/files
/aaa.txt
/bbb.txt
/srv
/index.html
Version: Caddy 2.4.6 in Docker.
P.S.: If you see the post on the caddy.community, it also me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
部署并提供项目的不同内容
使用要提供服务的
handle
和handle_path
指令来提供网站、API 和文件夹内容这是我为以下项目创建的示例项目相同的用户案例
Caddyfile,将
8080
替换为您的域名example.com
docker-compose.yml
Deploying and serving different contents of the project
Serve the website, API, and content of the folder with the
handle
andhandle_path
directives to serveHere is the sample project I created for the same usercase
Caddyfile, replace
8080
with your domainexample.com
docker-compose.yml