大家好,欢迎来到IT知识分享网。
Caddy是一个由Go语言编写的Web服务器软件,可以自动实现HTTPS部署。

为什么使用Caddy
自己的博客想要使用https,懒得去更新证书,Caddy可以快速解决我的问题。
而且相比nginx,Caddy部署起来更简单,就一个二进制文件;
CaddyFile配置更简单,很多都是默认配置,只要根据自己的情况,添加需要的参数即可。
功能丰富,但是很多我暂时用不到,用到再通过插件的方式添加即可。
对于一个博客应用来说完全够用了。

安装Caddy
在CentOS上可以直接使用yum安装的,也可以下载对应平台的二进制进行安装。

安装命令:
yum install yum-plugin-copr -y yum copr enable @caddy/caddy -y yum install caddy -y
配置
配置文件默认是在/etc/caddy/Caddyfile,配置文件只要修改好自己的域名,如果需要https直接填写上http://xxx就可以了,root执行自己的网站目录即可。

我的网站是hugo生成的静态站,直接配置目录。
如果是php可以直接转发的php_fastcgi。
# The Caddyfile is an easy way to configure your Caddy web server. # # Unless the file starts with a global options block, the first # uncommented line is always the address of your site. # # To use your own domain name (with automatic HTTPS), first make # sure your domain's A/AAAA DNS records are properly pointed to # this machine's public IP, then replace ":80" below with your # domain name. www.opcai.top https://www.opcai.top http://opcai.top https://opcai.top { # Set this path to your site's directory. root * /data/webroot # Enable the static file server. file_server # Another common task is to set up a reverse proxy: # reverse_proxy /back/* localhost:8080 # Or serve a PHP site through php-fpm: # php_fastcgi localhost:9000 } # Refer to the Caddy docs for more information: # https://caddyserver.com/docs/caddyfile
服务管理
systemctl enable --now caddy # 启动并设置开机启动 systemctl reload caddy # 重载配置
总结
Caddy还有很多强大的功能,慢慢探索。

<script type=”text/javascript” src=”//mp.toutiao.com/mp/agw/mass_profit/pc_product_promotions_js?item_id=”></script>
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/188585.html