1

Caddy Version: Caddy 0.10.10 (non-commercial use only)

I am using caddy as a reverse proxy for an ngnix server which happens to not have an index.html file in the web root.

So I have instead setup my own index.html file in the hopefully appropriate subdirectory of the the caddy web root. Caddyfile contents:

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

Contents of webroot

 index.html
        subdir
            index.html

What I wish to do is for caddy to instead of directing /subdir and /subdir/ to the proxied ngnix server but instead to serve the index.html file which resides in the subdir folder of the caddy webroot.

Some Tests I have tried are shown below Results are prefixed with #

1st Attempt

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.

2nd Attempt

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

3nd Attempt

For this one I tried moving the index file into the webroot and renaming it 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 .
Jfm Meyers
  • 123
  • 1
  • 12

0 Answers0