Using Caddy webserver for application on different host but same network

Hello,
I am quite new to Caddy. I am currently using Caddy for reverse proxy and would now want to use it as a webserver for a website of mine that is running on a different virtual machine on the same network.

1. Caddy version (caddy version): v2.2.1

2. How I run Caddy:

I am running Caddy on a virtual machine.

a. System environment:

VM is running Ubuntu 20.04 LTS

d. My complete Caddyfile or JSON config:

Refer to the Caddy docs for more information:

The Caddyfile — Caddy Documentation

vpn.pttxfre.local {
reverse_proxy https://10.222.0.50 {
transport http {
tls_insecure_skip_verify
}
}
}

utode.pttxfre.com {
reverse_proxy {
to https://10.222.0.4
transport http {
tls_insecure_skip_verify
}
}
}

3. The problem I’m having:

I would want to use it as a webserver for a website of mine whose application files are on a different virtual machine on the same network. How do I properly configure the Caddyfile so that I can use the Caddy webserver to run that website that is on another computer on the same network?

My website is seated on a VM whose IP is 10.222.0.12 running on a certain port 5000.
Location of website files is /home/pttxfre/mypttxfre

My Caddy server is on the same network with an IP 10.222.0.20

This is the configuration that I have come up with and would like to add to my Caddyfile but am not so sure bout it

10.222.0.12:5000 { //ip and port for the website
root * /home/pttxfre/mypttxfre //location of website files
file_server
}

What could be the correct configuration?
Thanks

6. Links to relevant resources:

That’s quite an old version at this point. Please upgrade to the latest, v2.4.3!

When you use https://, Caddy assumes port 443 for your proxy. You said you’re hosting it on port 5000? Then use 10.222.0.50:5000.

Your post is messy regarding syntax, so I might not understand what you’re asking. Please use triple backticks (```) on their own lines, before and after your configs/logs, to use code formatting, which preserves indentation/whitespace.

If the files you want to serve are on the same machine as Caddy, then you can use the file_server directive:

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