1

Caddy 版本:Caddy 0.10.10(仅限非商业用途)

我正在使用 caddy 作为 ngnix 服务器的反向代理,该服务器恰好在 web 根目录中没有 index.html 文件。

所以我改为在 caddy web 根目录的适当子目录中设置我自己的 index.html 文件。球童文件内容:

example.com {
     root webroot
     proxy /subdir backend {
         without /subdir
     }
}

webroot的内容

 index.html
        subdir
            index.html

我希望 caddy 不是将 /subdir 和 /subdir/ 定向到代理的 ngnix 服务器,而是提供驻留在 caddy webroot 的 subdir 文件夹中的 index.html 文件。

我尝试过的一些测试如下所示结果以#为前缀

第一次尝试

example.com {
     root webroot
     proxy /subdir backend {
         without /subdir
         except /subdir /subdir/
     }
}
# Does something unusual: it seems to return normal eg code 200 responses with a body length of zero.

第二次尝试

example.com {
     root webroot
     proxy /subdir backend {
         without /subdir
         except /
     }
}
# Technically works but causes the entire proxy directive to be nullified.

第三次尝试

对于这个我尝试将索引文件移动到 webroot 并将其重命名为 subdir_index.html

example.com {
     root webroot
     proxy /subdir backend {
         without /subdir
     }
     rewrite /subdir /subdir_index.html
     rewrite /subdir/ /subdir_index.html
}
# Seems to just change the file caddy requests from the proxy to proxy/_index.html while originally it attempted to request proxy/index.html .
4

0 回答 0