How can I write this in caddy 2
rewrite / {
r ^.*/$
to {path} {path}/ {dir}/index.html
}
Thanks
How can I write this in caddy 2
rewrite / {
r ^.*/$
to {path} {path}/ {dir}/index.html
}
Thanks
You’re looking for try_files
:
try_files {path} {path}/ /index.html
Thanks @francislavoie
This is working but only with root based on documentation
I need something that works with reverse_proxy
Please fill out the help topic template. You haven’t clearly explained what you’re trying to do.
Please follow the forum rules. You won’t get further help until you fill out the help template.
Solution was: uri path_regexp (.*)/$ $1/index.html
Thanks
caddy version
):v2.4.6
./caddy run --config myConfig
Docker
encode gzip
log
file_server
header {
# Disallow the site to be rendered within a frame on different domain (clickjacking protection)
+X-Frame-Options "SAMEORIGIN"
-Server
-x-powered-by
+Access-Control-Allow-Headers Range
+Access-Control-Expose-Headers "Accept-Ranges, Content-Encoding, Content-Length, Content-Range"
}
header /path1* {
+Access-Control-Allow-Origin "*"
}
route /website* {
uri replace /website /path1/path2/website
uri path_regexp (.*)/$ $1/index.html
reverse_proxy http://website_proxy:3333 {
header_down Content-Type ""
}
}
Redirect to index.html not working
The website is working if I manually add index.html for all paths [css, js are working correctly]
@francislavoie I came back as actually it is not working with this config
I don’t understand what you’re trying to do. You haven’t explained what requests need to be rewritten to what path.
It’s unusual to be performing rewrites to files when you’re using reverse_proxy
. The expectation typically is that your upstream app will do the routing itself.
I would like to:
If I understand correctly, you mean that if the path ends in /
you want to add index.html
? Yeah that’s easy:
@isDirectory path */
rewrite @isDirectory {path}index.html
This topic was automatically closed after 30 days. New replies are no longer allowed.