用ChatGpt来修改Caddy配置
type
Post
status
Published
date
Jun 26, 2023
slug
chatgpt-cady
summary
用chatgpt来辅助修改caddy配置
tags
技巧
开发
建站
category
技术分享
icon
password

背景

最近在帮朋友折腾WordPress站点,主站点包含了很多子站点(路径的形式),然后还附带有一个独立的Blog站点,路径也是在WordPress root下,这使得Caddyfile不是特别容易。
网上关于Caddy配置Wordpress多站点的资料也很少,所以就是来找Gpt帮忙。
 

我要实现的效果

 
https://llost.net (主站)
https://llost.net/xxx1 (子站点,会有几十个)
https://llost.net/blog (blog,独立的一套)
 
主站我已经配置好了,子站点用rewrite也实现了一部分,一会我会贴出完整的配置文件,blog是gpt帮我来实现
notion image
复制粘贴过去一切都是ok的,(我的blog目录是在rootwordpress下)。
这样我们实现了 https://llost.net/blog 的方式来访问独立的blog站点

Wordpress 多站点(path方式)的配置

 
我把我的配置贴出来:
www.llost.net llost.net { root * /var/www/wordpress php_fastcgi unix//run/php/php7.4-fpm.sock file_server encode gzip @disallowed { path /xmlrpc.php path *.sql path /wp-content/uploads/*.php } rewrite @disallowed '/index.php' # URL rewrites for WordPress @notRealFiles { not file path /blog/* } rewrite @notRealFiles /blog/index.php # Handle the WordPress permalinks @permalinks { not path /blog/wp-admin/* not file path /blog/* } rewrite @permalinks /blog/index.php?{query} @key12 { not file path_regexp key12 /([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) } rewrite @key12 /{re.key12.2} @key13 { not file path_regexp key13 /([_0-9a-zA-Z-]+/)?(.*.php) } rewrite @key13 /{re.key13.2} @key14 { not file path_regexp key14 /. } rewrite @key14 /index.php }
 

© Fat uncle 2024