I currently use caddy (with success) to reverse proxy a media server and some -arr apps. I’d like to host several websites on a single VPS, wondering if this could handle the traffic redirection.
Yes these are static sites. I have directory 1 and inside that are all the .css and html files for a website. I have directory 2 and inside that are all the .css and .html files for another static webpage. I want caddy to receive incoming requests like my.domain1.com and send that to directory1 and then my.domain2.com gets sent to directory2 and so on.
Thus I can host multiple websites on one VPS.
My current caddy file looks like this:
https://mytest.mediaserver.net {
# Set this path to your site's directory.
root /home/ubuntu/sites/test-site
}
But when I run caddy, it listens on port 2019 which I think is why I cannot reach the web site.
That’s invalid syntax – you need to use a * matcher with root because otherwise, the root will be parsed as a path matcher. See the docs, which explain:
Also, I strongly recommend moving your sites to /srv or /var/www/html. Having your files in /home can cause permission issues, since Caddy (running as a systemd service) doesn’t run as one of the login users, it uses the caddy user.
Also, you need to enable the file_server directive for Caddy to actually serve static files.
Caddy binds to port 2019 for its admin API, which is what allows you to gracefully reload Caddy’s config, and other things.
What’s in your logs? See this page in the docs, it explains how to see Caddy’s logs: