说明:Caddy
是一个轻量级的Web
服务器,安装和配置很快,博主也喜欢用,以后的使用范围估计会越来越广,而目前就是一些Web
应用程序的配置文件难找,相信很多人都有体会,这里博主就列举常用的一些程序的配置供参考。
配置
以下参数都需要填入配置文件Caddyfile
里,且仅作参考。
1、Chevereto图床
example.com {
root /var/www/chevereto
fastcgi / /var/run/php/php7.0-fpm.sock php
rewrite {
to {path} {path}/ /index.php?{query}
}
}
2、Nextcloud网盘
my-nextcloud-site.com {
root /var/www/nextcloud
log /var/log/nextcloud_access.log
errors /var/log/nextcloud_errors.log
fastcgi / 127.0.0.1:9000 php {
env PATH /bin
}
header / {
Strict-Transport-Security "max-age=15768000;"
}
# checks for images
rewrite {
ext .svg .gif .png .html .ttf .woff .ico .jpg .jpeg
r ^/index.php/(.+)$
to /{1} /index.php?{1}
}
rewrite {
r ^/\.well-known/host-meta$
to /public.php?service=host-meta&{query}
}
rewrite {
r ^/\.well-known/host-meta\.json$
to /public.php?service=host-meta-json&{query}
}
rewrite {
r ^/\.well-known/webfinger$
to /public.php?service=webfinger&{query}
}
rewrite {
r ^/index.php/.*$
to /index.php?{query}
}
# client support (e.g. os x calendar / contacts)
redir /.well-known/carddav /remote.php/carddav 301
redir /.well-known/caldav /remote.php/caldav 301
# remove trailing / as it causes errors with php-fpm
rewrite {
r ^/remote.php/(webdav|caldav|carddav|dav)(\/?)(\/?)$
to /remote.php/{1}
}
rewrite {
r ^/remote.php/(webdav|caldav|carddav|dav)/(.+?)(\/?)(\/?)$
to /remote.php/{1}/{2}
}
rewrite {
r ^/public.php/(dav|webdav|caldav|carddav)(\/?)(\/?)$
to /public.php/{1}
}
rewrite {
r ^/public.php/(dav|webdav|caldav|carddav)/(.+)(\/?)(\/?)$
to /public.php/{1}/{2}
}
# .htaccess / data / config / ... shouldn't be accessible from outside
status 403 {
/.htaccess
/data
/config
/db_structure
/.xml
/README
}
}
3、WordPress博客
配置参考该文章:Caddy环境下WordPress博客伪静态设置。
4、Typecho博客
配置参考该文章:小内存VPS安装Caddy+PHP 7+Sqlite 3环境,并快速搭建Typecho博客。
暂时只列举这些常用的,如果你需要更多程序的Web
配置,可以留言,博主尽量给你提供正确的配置文件。