I have a local web-application running on 127.0.0.1:8080. Now I am wondering if it’s possible to configure some kind of virtual host in Caddy like this:
127.0.0.1:8080 mysite.test
Preferably it should also be able to redirect to subdomains like this:
What do you mean by “redirect”? That has a very specific meaning in HTTP, i.e. responding with a Location header, telling the browser to make a new request at a different location.
Well, that’s not a thing, because Caddy is not a DNS server, like I said. It’s an HTTP server. Caddy handles HTTP requests, looks at the hostname in the request, and routes based on that (that’s a huge oversimplification, but I’m not sure how else to get the idea across).
To be clear, /etc/hosts is not an apache thing, it’s a Linux thing. It just tells your system how to resolve certain hosts that you specify to an IP address, as an override. Windows has the same in C:\Windows\System32\hosts if I remember the path correctly.