香港/韩国云服务器、独立服务器租用

Debian下Caddy2安装和管理

自营机房/高防服务器/高防VPS/美国高防/洛杉矶VPS/洛杉矶高防服务器

Caddy2安装:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
caddy –v   #检查是否安装成功

Caddy2管理:

# 启动Caddy2
systemctl start caddy
# 开机自启
systemctl enable caddy
# 重启Caddy2
systemctl restart caddy
# 停止Caddy2
systemctl stop caddy
# 重载配置Caddy配置文件(修改配置文件后执行)
systemctl reload caddy
# 查看Caddy2运行状态
systemctl status caddy 

Caddy2简单配置文件:

nano /etc/caddy/Caddyfile  #编辑文件
zrblog.net {
    redir https://www.zrblog.net{uri} permanent
}

www.zrblog.net {

    reverse_proxy *.*.*.*:80

    tls {
        protocols tls1.2 tls1.3
    }

    header {
        Permissions-Policy interest-cohort=()
        Strict-Transport-Security max-age=31536000;
        X-Content-Type-Options nosniff
        X-Frame-Options DENY
        Referrer-Policy no-referrer-when-downgrade
        -Via
        -Alt-Svc
    }

    log {
        output file /var/log/caddy/zrblog.net.log {
            roll_size 10mb
            roll_keep 5
        }
    }
}

本站QQ群:683851361,联系我:zrblog@qq.com

分享到
便宜VPS/10美元VPS/洛杉矶、圣何塞等多个机房