Reverse proxy with domain name

1. Caddy version:

v2.6.4 on Ubuntu

2. How I installed, and run Caddy:

Using the script within the help Caddy documentation. Direct installation within the OS. The linux server is not doing anything else and will only be a reverse proxy.

a. System environment:

Ubuntu 22 (Ubuntu 22.04.2 LTS)

b. Command:

caddy reverse-proxy --from :2015 --to

caddy reverse-proxy --from http://gci.localhost:2015 --to

c. Service/unit/compose file:


d. My complete Caddy config:

not using a caddy file

3. The problem I’m having:

I am trying to get a reverse proxy to work.

I have two servers: - simple apache server which will server a webpage on http port 80 - caddy which I want to be a reverse proxy and redirect traffic based or servername

When I run the command ‘caddy reverse-proxy --from :2015 --to’ it will work fine. When accessing I get the webpage from

I have changed my hosts.ini to direct all traffic from gci.localhost to A ping confirms this.

The caddy command ‘caddy reverse-proxy --from gci.localhost --to’ does not work. I have tried various combinations and cannot get http://gci.localhost to work and show me the webpage from

4. Error messages and/or full log output:

root@caddy:/# caddy reverse-proxy --from http://gci.localhost:2015 --to
2023/02/23 09:09:20.849 WARN admin admin endpoint disabled
2023/02/23 09:09:20.850 WARN http automatic HTTPS is completely disabled for server {“server_name”: “proxy”}
2023/02/23 09:09:20.852 INFO http.log server running {“name”: “proxy”, “protocols”: [“h1”, “h2”, “h3”]}
Caddy proxying http://gci.localhost:2015 →
2023/02/23 09:09:20.853 INFO tls cleaning storage unit {“description”: “FileStorage:/root/.local/share/caddy”}
2023/02/23 09:09:20.854 INFO tls finished cleaning storage units
2023/02/23 09:09:20.855 INFO tls.cache.maintenance started background certificate maintenance {“cache”: “0xc0000d8f50”}

5. What I already tried:

I have tried all manner of combinations. I cannot get a hostname to ever be proxied by caddy.

6. Links to relevant resources:

That’s normal behaviour. If you configure --from with a domain, then Caddy will only respond to requests with that hostname.

That doesn’t work. Many clients always resolve *.localhost to ignoring all DNS/hosts config. It doesn’t make sense to use a non-localhost IP address for a localhost domain.


That was exacly the problem. I needed to use a dummy .com domain.

1 Like

The more “correct” TLD to use is * FWIW. Using *.test is fine too.

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