这是我的Caddyfile
aruiplex.com {
encode gzip
file_server /files/* {
root /files
browse
}
reverse_proxy /api/* localhost:7022
file_server {
root /srv
}
}以下是我的计划:
aruiplex.com时,Caddy可以在/srv目录中向我显示index.html。aruiplex.com/files时,Caddy可以将文件列表显示在停靠容器中的/files目录中。aruiplex.com/api时,Caddy可以将此请求传递给localhost:7022。但是当我请求aruiplex.com/files文件服务器不工作时,它会给我一个404。我检查了这个目录在码头集装箱,有一些文件。
下面是我在码头容器中的/文件树:
/
/home
/etc
/...
/files
/aaa.txt
/bbb.txt
/srv
/index.html版本:卡迪2.4.6在码头。
P.S.:如果你看到caddy.community上的帖子,也是我。
发布于 2022-03-28 14:05:20
部署和服务项目的不同内容
使用handle和handle_path指令服务文件夹的网站、API和内容
下面是我为同一个用例创建的示例项目
├── Caddyfile
├── app
│ └── index.html
├── docker-compose.yml
├── files
│ ├── bye.txt
│ └── hello.txt
└── logs
└── access.logCaddyfile,将8080替换为域example.com
:8080 {
handle /api* {
reverse_proxy localhost:7022
}
handle_path /files* {
root * /files
file_server browse
}
handle {
root * /srv
file_server browse
}
}
:7022 {
respond "Hey! I AM API"
}docker-compose.yml
version: "3"
services:
caddy:
restart: always
image: caddy:2.4.6
container_name: caddy
ports:
- 8080:8080 # Configure Caddyfile with port opened
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
- ./app:/srv
- ./files:/files
- ./logs:/var/log
volumes:
caddy_data:
caddy_config:https://stackoverflow.com/questions/71411688
复制相似问题