1. Caddy version (caddy version
):
v2.0.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
2. How I run Caddy:
sudo apt install caddy
a. System environment:
Ubuntu 18.04.2 LTS, fresh and clear.
b. Command:
sudo caddy start --config Caddyfile --watch
c. Service/unit/compose file:
N/A
d. My complete Caddyfile or JSON config:
myWebSiteFoo.com {
reverse_proxy /t1 localhost:8760
reverse_proxy /t1/* localhost:8760
reverse_proxy /t2 localhost:8761
reverse_proxy /t2/* localhost:8761
}
localhost:8760 {
root * /home/username/app/Test/t1/dist
file_server
}
localhost:8761 {
root * /home/username/app/Test/t2/dist
file_server
}
3. The problem I’m having:
I want to host my static web sites under a same domain, split it with routes. I.E.
Visit myWebSiteFoo.com/t1
the server returns the file /home/username/app/Test/t1/dist
, and
Visit myWebSiteFoo.com/t2
returns /home/username/app/Test/t2/dist
But I do got response with curl https://localhost:8761
on the server. (The response is the content of index.html
.) (BTW, curl localhost:8761
just returns “Client sent an HTTP request to an HTTPS server”.)
If I use caddy just to reverse_proxy, not use as a file_server, and use another process like Node.js to host my website on localhost:port, the whole thing works well. Visit myWebSiteFoo.com/t2
can get response.
Is something wrong with my caddyfile?
4. Error messages and/or full log output:
No error, the request returns blank.
5. What I already tried:
Caddyfile directives like: route, rewrite, redir, root, uri strip_prefix.
Config the website with a base url, i.e curl https://localhost:8761/t2
on server works correctly.
6. Links to relevant resources:
N/A