Help with Caddyfile

1. The problem I’m having:

I’m trying to have a multiple file webserver and to have a path /api/* be a reverse proxy to a http (not https) backend webserver

2. Error messages and/or full log output:

I don't have an error I just don't know how to do this.

3. Caddy version:

v2.10.0 h1:fonubSaQKF1YANl8TXqGcn4IbIRUDdfAkpcsfI/vX5U=

4. How I installed and ran Caddy:

sudo apt-get install caddy
caddy run

a. System environment:

Lunix Ubuntu

b. Command:

caddy run

d. My complete Caddy config:

site.raidxmc.org {
  root * /root/site/RaidXSite
  file_server

  handle_path /api/* {
		reverse_proxy http://82.23.170.99:25569
	}

  try_files {path} /index.html

}

5. Links to relevant resources:

none

Take a look at the docs for Directive Order.

If you’re clear on the difference between

  handle_path /api/* {

and

  handle /api/* {

you probably want something like this:

site.raidxmc.org {

  redir /api /api/

  handle_path /api/* {
    reverse_proxy http://82.23.170.99:25569
  }

  handle {
    root * /root/site/RaidXSite
    file_server
    try_files {path} /index.html
  }
}
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.