Caddy简单使用
1 参考文档
# 官方网址https://caddyserver.com/# github上文档https://github.com/caddyserver/caddy# 配置Caddyfilehttps://caddyserver.com/docs/caddyfile
2 安装caddy
2.1 docker安装
# 下载caddydocker pull caddy:2.6.2# 安装caddy容器docker run -itd \--name my_caddy \-p 80:80 \-p 443:443 \-v /home/caddy/srv:/srv \-v /home/caddy/data:/data \-v /home/caddy/config:/config \caddy:2.6.2# 验证服务,输入IP地址(我的IP地址是"192.168.108.200"http://192.168.108.200/
2.2 安装成功后截图
2.3 常用命令
# 启动caddy caddy start# 停止caddycaddy stop# 重新加载配置文件caddy reload
3 配置“Caddyfile”文件
“Caddyfile”文件在”/etc/caddy/Caddyfile“目录下
3.1 ”Caddyfile“文件默认内容
# The Caddyfile is an easy way to configure your Caddy web server.## Unless the file starts with a global options block, the first# uncommented line is always the address of your site.## To use your own domain name (with automatic HTTPS), first make# sure your domain's A/AAAA DNS records are properly pointed to# this machine's public IP, then replace ":80" below with your# domain name.:80 {# Set this path to your site's directory.# “root”表示指定站点的根目录# “*”表示匹配所有请求# “/usr/share/caddy”表示静态文件目录root * /usr/share/caddy# Enable the static file server.file_server# Another common task is to set up a reverse proxy:# reverse_proxy localhost:8080# Or serve a PHP site through php-fpm:# php_fastcgi localhost:9000}# Refer to the Caddy docs for more information:# https://caddyserver.com/docs/caddyfile
3.2 共享文件列表
# 进入容器docker exec -it my_caddy /bin/sh# 编辑Caddyfilevim Caddyfile# 编辑的内容:80 {file_server browse {root /data/file }}
3.2 浏览目录
来源地址:https://blog.csdn.net/make_progress/article/details/127465581