Caddy Install

下载地址

页面底部会生成一键安装命令
https://caddyserver.com/download

配置文件

website.com {
tls **@qq.com{   #启用HTTPS,并使用使用此账户自动申请Let's Encrypt的HTTPS证书
                protocols tls1.0 tls1.2   #设置最低和最高的https协议
}
gzip
header / {
    # Enable HSTS. https://mdn.io/HSTS
    Strict-Transport-Security "max-age=15768000"
    # Enable stricter XSS protection. https://mdn.io/X-XSS-Protection
    X-XSS-Protection "1; mode=block"
    # Prevent MIME-sniffing. https://mdn.io/X-Content-Type-Options
    X-Content-Type-Options "nosniff"
    # Prevent clickjacking. https://mdn.io/X-Frame-Options
    X-Frame-Options "DENY"
}
proxy / 127.0.0.1:9000 {
                websocket
                transparent
        }
}

简单安装为服务的方法

caddy -service install -agree=true -conf=/etc/caddy/Caddyfile

systemd Service for Caddy  

Assume that user `www-data` is already exists.  Make and configure Caddy directories.  
sudo mkdir /etc/caddy
sudo mkdir /etc/ssl/caddy
sudo chown -R root:www-data /etc/caddy
sudo chown -R root:www-data /etc/ssl/caddy
sudo chmod 0770 /etc/ssl/caddy

Copy Caddyfile.

sudo cp ./Caddyfile /etc/caddy/Caddyfile
sudo chown www-data:www-data /etc/caddy/Caddyfile
sudo chmod 444 /etc/caddy/Caddyfile

安装为系统服务

curl -k https://raw.githubusercontent.com/mholt/caddy/master/dist/init/linux-systemd/caddy.service -O /etc/systemd/system/caddy.service
systemctl daemon-reload
systemctl enable $PWD/caddy.service
systemctl start $PWD/caddy.service

懒人一键包

wget https://raw.githubusercontent.com/sayem314/Caddy-Web-Server-Installer/master/caddy.sh -O - -o /dev/null|bash