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

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

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

Caddy是一個(gè)由Go語(yǔ)言編寫的Web服務(wù)器軟件,可以自動(dòng)實(shí)現(xiàn)HTTPS部署。

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

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

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

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

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

對(duì)于一個(gè)博客應(yīng)用來(lái)說(shuō)完全夠用了。

安裝Caddy

在CentOS上可以直接使用yum安裝的,也可以下載對(duì)應(yīng)平臺(tái)的二進(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 # 啟動(dòng)并設(shè)置開機(jī)啟動(dòng) systemctl reload caddy # 重載配置 總結(jié)

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

分享名稱:使用Caddy作為Web服務(wù)器
分享路徑:http://www.bm7419.com/news1/204501.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、定制網(wǎng)站、網(wǎng)站策劃靜態(tài)網(wǎng)站、網(wǎng)站內(nèi)鏈、全網(wǎng)營(yíng)銷推廣

廣告

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

成都做網(wǎng)站