使用Caddy作為Web服務(wù)器

2022-10-11    分類: 網(wǎng)站建設(shè)

使用Caddy作為Web服務(wù)器

Caddy是一個由Go語言編寫的Web服務(wù)器軟件,可以自動實現(xiàn)HTTPS部署。

使用Caddy作為Web服務(wù)器 為什么使用Caddy

自己的博客想要使用https,懶得去更新證書,Caddy可以快速解決我的問題。

而且相比nginx,Caddy部署起來更簡單,就一個二進(jìn)制文件;

CaddyFile配置更簡單,很多都是默認(rèn)配置,只要根據(jù)自己的情況,添加需要的參數(shù)即可。

功能豐富,但是很多我暫時用不到,用到再通過插件的方式添加即可。

對于一個博客應(yīng)用來說完全夠用了。

安裝Caddy

在CentOS上可以直接使用yum安裝的,也可以下載對應(yīng)平臺的二進(jìn)制進(jìn)行安裝。

使用Caddy作為Web服務(wù)器

安裝命令:

yum install yum-plugin-copr -y yum copr enable @caddy/caddy -y yum install caddy -y 配置

配置文件默認(rèn)是在/etc/caddy/Caddyfile,配置文件只要修改好自己的域名,如果需要https直接填寫上http://xxx就可以了,root執(zhí)行自己的網(wǎng)站目錄即可。

我的網(wǎng)站是hugo生成的靜態(tài)站,直接配置目錄。

如果是php可以直接轉(zhuǎn)發(fā)的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, thenreplace":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 istoset 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 服務(wù)管理 systemctl enable --now caddy # 啟動并設(shè)置開機(jī)啟動 systemctl reload caddy # 重載配置 總結(jié)

Caddy還有很多強(qiáng)大的功能,慢慢探索。

本文名稱:使用Caddy作為Web服務(wù)器
轉(zhuǎn)載來源:http://muchs.cn/news/204501.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗網(wǎng)站排名、響應(yīng)式網(wǎng)站、商城網(wǎng)站、網(wǎng)站設(shè)計、品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營