1. My Caddy version (caddy -version
):
(devel) v2 (compiled to fix the php socket bug)
2. How I run Caddy:
./caddy adapt --config ./Caddyfile --pretty > caddy.json
a. System environment:
Debian 10.2, go1.13.5
d. My complete Caddyfile:
halcyon.domain.tld {
tls user@domain.tld
php_fastcgi / 127.0.0.1:9000 php
root /opt/halcyon
status 404 {
/config.ini
/.bat
/.git
/.ini
/.sh
/.svn
/.txt
/.tpl
/.xml
}
header / {
# Enable HTTP Strict Transport Security (HSTS) to force clients to always
# connect via HTTPS (do not use if only testing)
Strict-Transport-Security "max-age=31536000;"
# Enable cross-site filter (XSS) and tell browser to block detected attacks
X-XSS-Protection "1; mode=block"
# Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
X-Content-Type-Options "nosniff"
# Disallow the site to be rendered within a frame (clickjacking protection)
X-Frame-Options "DENY"
}
# Begin Main
rewrite {
r ^/home/?$
to /
}
rewrite {
r ^/intent/toot/?$
to /share.php
}
rewrite {
r ^/login/?$
to /login/login.php
}
rewrite {
r ^/auth/?$
to /login/auth.php
}
rewrite {
r ^/logout/?$
to /login/logout.php
}
rewrite {
r ^/terms/?$
to /login/terms.php
}
rewrite {
r ^/privacy/?$
to /login/privacy.php
}
rewrite {
r ^/imprint/?$
to /login/imprint.php
}
# End Main
# LTL
rewrite {
r ^/local/?$
to /local.php
}
# FTL
rewrite {
r ^/federated/?$
to /federated.php
}
# Notice
rewrite {
r ^/notifications/?$
to /notifications.php
}
# Who to follow
rewrite {
r ^/whotofollow/?$
to /who_to_follow.php
}
# Direct
rewrite {
r ^/direct/?$
to direct.php
}
# Instance
rewrite {
r ^/instance/?$
to instance.php
}
# Begin Lists
rewrite {
r ^/lists/?$
to lists.php
}
rewrite {
r ^/lists/(\d+)/?$
to lists_view.php?id={1}
}
rewrite {
r ^/lists/(\d+)/add/?$
to lists_add.php?id={1}
}
# End Lists
# Begin Search
rewrite {
r ^/search/?$
to /search_hash_tag.php
}
rewrite {
r ^/search/users/?$
to /search_user.php
}
# End Search
# Begin Settings
rewrite {
r ^/settings/?$
to /settings_general.php
}
rewrite {
r ^/settings/profile/?$
to /settings_profile.php
}
rewrite {
r ^/settings/appearance/?$
to /settings_appearance.php
}
rewrite {
r ^/settings/filters/?$
to /settings_filters.php
}
rewrite {
r ^/settings/media/?$
to /settings_media.php
}
rewrite {
r ^/settings/followers/?$
to /settings_accounts.php
}
rewrite {
r ^/settings/mutes/?$
to /settings_accounts.php
}
rewrite {
r ^/settings/blocks/?$
to /settings_accounts.php
}
# End settings
# Begin user
rewrite {
r ^/@(.+)@(.+)\.([a-z]+)/?$
to /user.php?user=@{1}@{2}.{3}
}
rewrite {
r ^/@(.+)@(.+)\.([a-z]+)/status/(.+?)?$
to /user.php?user=@{1}@{2}\.{3}&status={4}
}
rewrite {
r ^/@(.+)@(.+)\.([a-z]+)/media/?$
to /user_only_media.php?user=@{1}@{2}\.{3}
}
rewrite {
r ^/@(.+)@(.+)\.([a-z]+)/with_replies/?$
to /user_include_replies.php?user=@{1}@{2}\.{3}
}
rewrite {
r ^/@(.+)@(.+)\.([a-z]+)/followers/?$
to /user_followers.php?user=@{1}@{2}\.{3}
}
rewrite {
r ^/@(.+)@(.+)\.([a-z]+)/following/?$
to /user_following.php?user=@{1}@{2}\.{3}
}
rewrite {
r ^/@(.+)@(.+)\.([a-z]+)/favourites/?$
to /user_favorite.php?user=@{1}@{2}\.{3}
}
# End User
# Begin Image
rewrite {
r ^/avatars/original/missing.png$
to /assets/images/missing.png
}
rewrite {
r ^/headers/original/missing.png$
to /assets/images/missing_header.png
}
# End Image
# 404
rewrite {
r ^/404/?$
to /404.php
}
}
3. The problem Iām having:
Iām trying to have the above Caddyfile rewritten to json for v2 usage, however it shows that the āstatusā directive is unrecognized and that the rewrites have a wrong argument count.
4. Error messages and/or full log output:
adapt: Caddyfile:5: unrecognized directive: status
same goes with header
(after commenting out the status/header brackets):
adapt: parsing caddyfile tokens for ārewriteā: Caddyfile:18 - Error during parsing: Wrong argument count or unexpected line ending after ārewriteā
It seems that the Caddyfile syntax also changed from v1 to v2, thought it was only having it parsed to json, if someone could change one or two of the rules above as an example and convert the status/header settings block It would be greatly appreciated. Iām currently moving 95 sites over to
caddy2 and understanding rewrites and statuses/header usage in v2 would be really helpful.
I saw that header was rewritten to headers and statuses is supposed to be respond, but I wonder how to put multiple urls to one status as shown in the config above. But Iām still clueless on how to convert the rewrites.