中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

Caddy Server的使用介紹

2019-05-28    來源:愛站科技

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬Linux鏡像隨意使用

Caddy是Go寫的服務(wù)器軟件,它擁有基本的apache或者nginx有的web server模塊,同時(shí)還有一些很有特色的功能,那么你知道要如何使用Caddy Server嗎?我們現(xiàn)在就去看看Caddy Server的使用介紹吧。

HTTP/2
Automatic HTTPS
Multi-core
Websockets
Markdown
IPv6
Git
…...
用Caddy我們就可以很方便的部署一個(gè)Markdown文本作為靜態(tài)網(wǎng)站訪問,或者它的Git指令完成代碼的自動(dòng)化部署,當(dāng)然它很大的特色就是它的語法非常簡(jiǎn)潔,比nginx還要簡(jiǎn)單,配置部署起來很方便,下面隨便舉幾個(gè)例子吧。

對(duì)網(wǎng)站添加BasicAuth,用戶名ryan,密碼 12345

basicauth / ryan 12345

用CORS解決跨域問題

cors / {
??? origin??????????? http://allowedSite.com
??? origin??????????? http://anotherSite.org https://anotherSite.org
??? methods?????????? POST,PUT
??? allow_credentials false
??? max_age?????????? 3600
??? allowed_headers?? X-Custom-Header,X-Foobar
??? exposed_headers?? X-Something-Special,SomethingElse
}

IP過濾

ipfilter / {
??? rule?????? block
??? ip???????? 212.10.15.0-255 213.10.15.0-10 5.23.4.24
??? blockpage? /local/data/default.html
}

HTTPS 配置
tls ../cert.pem ../key.pem
實(shí)在太簡(jiǎn)單了配置起來,具體還有其他簡(jiǎn)潔到哭的指令可以看官方的User Guide,很快就刷完了。

既然Caddy自動(dòng)部署https,而且是通過Let's Encrypt,那么就實(shí)踐一下,本博客是用Ghost 搭建,Nginx代理的,現(xiàn)在就改用Caddy,并支持https,步驟大體如下:

證書申請(qǐng)請(qǐng)移步 Let's Encrypt
Caddy 安裝很簡(jiǎn)單,直接下載 https://caddyserver.com/docs/getting-started
配置Caddyfile,看起來指令簡(jiǎn)潔明了

https://www.yuansir-web.com, http://www.yuansir-web.com, http://yuansir-web.com {
 redir https://yuansir-web.com{uri}
 tls yuansir88@gmail.com
}

https://yuansir-web.com {
 gzip
 errors {
  log /var/log/caddy/yuansir-web.error.log {
    size 50
    age 30
    keep 5
  }
 }
 log /var/log/caddy/yuansir-web.access.log
 tls yuansir88@gmail.com
 proxy / http://127.0.0.1:2368 {
  proxy_header X-Real-IP {remote}
  proxy_header HOST {host}
  proxy_header X-Forwarded-Proto {scheme}
 }
}

用supservisor來管理Caddy運(yùn)行

[program:caddy]
command=/usr/bin/caddy -conf="/var/www/Caddyfile"
directory=/var/www  ; directory to cwd to before exec (def no cwd)
autostart=true    ; start at supervisord start (default: true)
autorestart=unexpected  ; whether/when to restart (default: unexpected)
startsecs=1     ; number of secs prog must stay running (def. 1)
startretries=3    ; max # of serial start failures (default 3)
exitcodes=0,2     ; 'expected' exit codes for process (default 0,2)
stopsignal=QUIT    ; signal used to kill process (default TERM)
stopwaitsecs=10    ; max num secs to wait b4 SIGKILL (default 10)
stopasgroup=false    ; send stop signal to the UNIX process group (default false)
user=www    ; setuid to this UNIX account to run the program
redirect_stderr=true   ; redirect proc stderr to stdout (default false)
stdout_logfile=/var/log/caddy.log  ; stdout log path, NONE for none; default AUTO
stderr_logfile=/var/log/caddyerr.log  ; stderr log path, NONE for none; default AUTO

將網(wǎng)站的靜態(tài)資源CDN換成支持https的CDN
以上就是Caddy Server的使用介紹,是不是覺得很簡(jiǎn)單呢,只要將Nginx切換成Caddy,并支持https了,就可以了。

標(biāo)簽: [db:TAGG]

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:nginx反向代理配置及優(yōu)化的介紹

下一篇:熱門的Linux服務(wù)器配置介紹