1. My Caddy version (caddy -version
):
1.0.4-1
2. How I run Caddy:
Systemd unit file
a. System environment:
Archlinux Systemd
https://aur.archlinux.org/packages/caddy/
b. Command:
/usr/bin/caddy -log stdout -agree -conf /etc/caddy/caddy.conf -root /tmp -default-sni mydomain.com
c. Service/unit/compose file:
cat /usr/lib/systemd/system/caddy.service
[Unit]
Description=Caddy HTTP/2 web server
Documentation=https://caddyserver.com/docs
After=network-online.target
[Service]
User=http
Group=http
Environment=CADDYPATH=/var/lib/caddy
EnvironmentFile=-/etc/caddy/envfile
ExecStart=/usr/bin/caddy -log stdout -agree -conf /etc/caddy/caddy.conf -root /tmp
ExecReload=/usr/bin/kill -USR1 $MAINPID
LimitNOFILE=1048576
LimitNPROC=64
PrivateTmp=true
PrivateDevices=true
ProtectHome=true
ProtectSystem=strict
ReadWritePaths=/var/lib/caddy /var/log/caddy
AmbientCapabilities=CAP_NET_BIND_SERVICE
cat /etc/systemd/system/caddy.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/caddy -log stdout -agree -conf /etc/caddy/caddy.conf -root /tmp -default-sni mydomain.com
ReadWritePaths=/var/lib/quassel
d. My complete Caddyfile:
https://mydomain.com {
root /var/www
gzip
header / Cache-Control "no-cache"
tls myemail@gmail.com
on certrenew /usr/local/bin/update-quasselcert
fastcgi / /var/run/php-fpm/php-fpm.sock php
jwt {
path /
except /favicon.ico
except /public
except /tautulli/api
redirect /login?backTo={rewrite_uri}
}
login {
htpasswd file=/etc/caddy/passwd
redirect_check_referer false
}
rewrite {
r /logout$
to /login?logout=true
}
status 404 /notfound
rewrite {
r /\.(git|htaccess)|/rutorrent/(conf|share)
to /notfound
}
proxy /sonarr 127.0.0.1:8989 {
transparent
}
proxy /radarr 127.0.0.1:7878 {
transparent
}
proxy /lidarr 127.0.0.1:8686 {
transparent
}
proxy /tautulli 127.0.0.1:8181 {
transparent
}
redir /sync /sync/
proxy /sync/ 127.0.0.1:8888/gui/ {
without /sync/
transparent
}
proxy /gui 127.0.0.1:8888 {
transparent
}
}
http://localhost {
root /var/www
gzip
header / Cache-Control "no-cache"
fastcgi / /var/run/php-fpm/php-fpm.sock php
}
http://mydomain.com/public {
root /var/www/public
gzip
header / Cache-Control "no-cache"
fastcgi / /var/run/php-fpm/php-fpm.sock php
}
3. The problem I’m having:
I have my main domain defined and would like automatic http to https redirect.
I have one directory, /public, that I would like available over http or https without an automatic redirect. I’ve defined that location at the bottom of my caddy file. This is woking well and I can access files in /public over http or https.
The problem is that this has broken the automatic http to https redirect for the rest of the site.
Any way I can make one directory available over http but maintain the automatic http to https redirect?