Nginx換用Caddy
由於無聊買的50vz的NAT OVZ機器被TCP阻斷,也是研究怎麼通過UDP來瞎搞,但是發現V2Ray w/ mKCP會有斷流的情況,雖然我極度懷疑是運營商搞的鬼,但一搜卻發現有人做內網測試也是會斷流……即使我升級到最新的4.2也然並卵,不過這個過程中我發現有人用Caddy搭建ws代理……於是手癢的我也把Nginx換成Caddy。
現在大概記一下,
首先是ofollow,noindex" target="_blank">去 Caddy獲取一句話安裝命令 ,大概類似這樣:
$ curl https://getcaddy.com | bash -s personal hook.service,http.cgi,http.geoip
然後在shell裡面執行即可,簡單的通過執行caddy -version 就能看是否裝上了;
之後根據各類教程和官方文件,寫了一個很簡單的配置,大概如下:
mr21.cc { tls [email protected] root /path/to/21 gzip fastcgi / /run/php/php7.0-fpm.sock php rewrite { if {path} not_match ^\/wp-admin to {path} {path}/ /index.php?_url={uri} } }
之後安裝systemctl控制指令碼:
$ sudo curl -s https://raw.githubusercontent.com/mholt/caddy/master/dist/init/linux-systemd/caddy.service -o /etc/systemd/system/caddy.service $ sudo systemctl daemon-reload $ sudo systemctl enable caddy $ sudo systemctl start caddy
最後開啟WP,登陸後臺,發現古騰堡(Gutenberg)外掛有報錯:
TypeError: Cannot read property 'show_ui' of undefined at https://mr21.cc/wp-content/plugins/gutenberg/build/editor/index.js?ver=1541761675:50:249655 at i (https://mr21.cc/wp-content/plugins/gutenberg/vendor/lodash.min.59550321.js:6:91) at An.filter (https://mr21.cc/wp-content/plugins/gutenberg/vendor/lodash.min.59550321.js:99:338) at https://mr21.cc/wp-content/plugins/gutenberg/build/editor/index.js?ver=1541761675:50:249620 at yh (https://mr21.cc/wp-content/plugins/gutenberg/vendor/react-dom.min.82e21c65.js:95:430) at lg (https://mr21.cc/wp-content/plugins/gutenberg/vendor/react-dom.min.82e21c65.js:120:88) at mg (https://mr21.cc/wp-content/plugins/gutenberg/vendor/react-dom.min.82e21c65.js:120:386) at gc (https://mr21.cc/wp-content/plugins/gutenberg/vendor/react-dom.min.82e21c65.js:127:202) at vb (https://mr21.cc/wp-content/plugins/gutenberg/vendor/react-dom.min.82e21c65.js:126:230) at ub (https://mr21.cc/wp-content/plugins/gutenberg/vendor/react-dom.min.82e21c65.js:126:65)
一番搜尋後WordPress/gutenberg/issues/8802" rel="nofollow,noindex" target="_blank">找到解決方法 ,將Caddy官方建議配置中的:
rewrite { if {path} not_match ^\/wp-admin to {path} {path}/ /index.php?_url={uri} }
換成
rewrite { if {path} not_match ^\/wp-admin to {path} {path}/ /index.php?{query} }
就可以了。
最後,既然是HTTPS站點,就順便跑了一下SSL Labs的測試,發現評分只有A,於是又搜了一下,找到Caddy社群的一篇問答 解決,評分上到A+,只需要在站點配置裡面加一句:
header / Strict-Transport-Security "max-age=31536000"
這篇就是用古騰堡寫的,感覺還是不太習慣用視覺化編輯器,雖然說比自己寫各種標籤方便很多,但是還是覺得……少了點啥……哈哈
——————–
引用參考/Reference:
- 怡紅院落: 使用 CADDY 代替 NGINX
- NightFarmer’s Blog: 使用新一代的Web伺服器Caddy代替Nginx
- Diamond-Blog: 使用 Caddy 替代 Nginx,全站升級 https,配置更加簡單
- Gutenberg@Github: issue #8802
- Caddy FORUM: Anyone archived A+ rating on SSL Labs?