十年網(wǎng)站開發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專業(yè)推廣+無(wú)憂售后,網(wǎng)站問題一站解決
Caddy Web 服務(wù)器是一個(gè)開源的、支持 HTTP/2 的 Web 服務(wù)器,使用 Go 語(yǔ)言編寫。Caddy 最顯著的功能之一是自動(dòng)為托管網(wǎng)站啟用 TLS。Caddy 自動(dòng)從 Let’s Encrypt 獲取和更新 TLS 證書。Caddy 也可以配置為反向代理服務(wù)器。

系統(tǒng):Centos8
主機(jī)名: caddy.example.com
IP地址:192.168.43.131
使用下面命令安裝caddy:
[root@caddy ~]# yum -y install 'dnf-command(copr)'
[root@caddy ~]# yum copr enable @caddy/caddy
[root@caddy ~]# yum -y install caddy
找到 Caddy Web 服務(wù)器的安裝目錄:
[root@caddy ~]# whereis caddy
caddy: /usr/bin/caddy /etc/caddy /usr/share/caddy
CentOS 8 安裝 Caddy Web服務(wù)器CentOS 8 安裝 Caddy Web服務(wù)器
下面為Caddy服務(wù)創(chuàng)建存放證書的目錄:
[root@caddy ~]# mkdir /etc/ssl/caddy
[root@caddy ~]# chown -R caddy:root /etc/ssl/caddy/
[root@caddy ~]# chmod o-rwx /etc/ssl/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
在瀏覽器輸入服務(wù)器ip地址,可訪問默Caddy的默認(rèn)頁(yè)面。
在Caddyfile文件中創(chuàng)建一個(gè)簡(jiǎn)單的服務(wù)器配置:
[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 "Hello World
" > /var/www/html/index.html
重啟一下caddy服務(wù):
[root@localhost ~]# systemctl restart caddy
訪問測(cè)試一下: 防火墻開啟http:
[root@localhost ~]# firewall-cmd --permanent --add-service=http
success
[root@localhost ~]# firewall-cmd --reload
success