-
支持 HTTP/1.1 和 HTTP/2
-
自动配置HTTPS
-
支持虚拟主机
-
IPv4和IPv6
-
反向代理
-
带健康检查的负载平衡
-
GZip压缩
环境信息
安装Caddy Web服务器
[root@caddy ~]# yum -y install 'dnf-command(copr)'
[root@caddy ~]# yum copr enable @caddy/caddy
[root@caddy ~]# yum -y install caddy
[root@caddy ~]# whereis caddy
caddy: /usr/bin/caddy /etc/caddy /usr/share/caddy
为 Caddy Web 服务器创建目录结构
[root@caddy ~]# mkdir /etc/ssl/caddy
[root@caddy ~]# chown -R caddy:root /etc/ssl/caddy/
[root@caddy ~]# chmod o-rwx /etc/ssl/caddy/
启用caddy服务
[root@caddy ~]# systemctl enable caddy
Created symlink /etc/systemd/system/multi-user.target.wants/caddy.service → /usr/lib/systemd/system/caddy.service.
[root@caddy ~]# systemctl start caddy
在 Caddyfile 中创建一个服务器配置
[root@caddy ~]# vim /etc/caddy/Caddyfile
:80 {
# Set this path to your site's directory.
root * /var/www/html
# Enable the static file server.
file_server
gzip
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}
[root@caddy html]# echo "<h1>Hello World</h1>" > /var/www/html/index.html
[root@localhost ~]# systemctl restart caddy
[root@localhost ~]# firewall-cmd --permanent --add-service=http
success
[root@localhost ~]# firewall-cmd --reload
success
总 结
END
官方站点:www.linuxprobe.com
Linux命令大全:www.linuxcool.com
刘遄老师QQ:5604241
Linux技术交流群:3586725
(新群,火热加群中……)
想要学习Linux系统的读者可以点击"阅读原文"按钮来了解书籍《Linux就该这么学》,同时也非常适合专业的运维人员阅读,成为辅助您工作的高价值工具书!
文章评论