使用Caddy作為Web服務器

2022-10-11    分類: 網站建設

使用Caddy作為Web服務器

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

使用Caddy作為Web服務器 為什么使用Caddy

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

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

CaddyFile配置更簡單,很多都是默認配置,只要根據自己的情況,添加需要的參數即可。

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

對于一個博客應用來說完全夠用了。

安裝Caddy

在CentOS上可以直接使用yum安裝的,也可以下載對應平臺的二進制進行安裝。

使用Caddy作為Web服務器

安裝命令:

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

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

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

如果是php可以直接轉發(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 服務管理 systemctl enable --now caddy # 啟動并設置開機啟動 systemctl reload caddy # 重載配置 總結

Caddy還有很多強大的功能,慢慢探索。

分享名稱:使用Caddy作為Web服務器
分享路徑:http://www.muchs.cn/news1/204501.html

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

廣告

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

成都做網站