Cannot get a reverse proxy to work

1. Caddy version (caddy version):

v2.4.6

2. How I run Caddy:

a. System environment:

On a ubuntu 20.04 VM. A fresh install using the setup steps outlined at Install — Caddy Documentation

b. Command:

vi Caddyfile
caddy fmt --overwrite Caddyfile
caddy adapt
caddy reload

c. Service/unit/compose file:

Not using Docker. Was a installation straght onto the OS.

d. My complete Caddyfile or JSON config:

localhost:3000

reverse_proxy {
to 192.168.0.210:80
}

3. The problem I’m having:

gck@caddy-1:~$ curl -v http://192.168.0.239:3000/

  • Trying 192.168.0.239:3000…
  • TCP_NODELAY set
  • Connected to 192.168.0.239 (192.168.0.239) port 3000 (#0)

GET / HTTP/1.1
Host: 192.168.0.239:3000
User-Agent: curl/7.68.0
Accept: /

  • Mark bundle as not supporting multiuse
  • HTTP 1.0, assume close after body
    < HTTP/1.0 400 Bad Request
    <
    Client sent an HTTP request to an HTTPS server.
  • Closing connection 0

gck@caddy-1:~$ curl -v localhost:3000

  • Trying 127.0.0.1:3000…
  • TCP_NODELAY set
  • Connected to localhost (127.0.0.1) port 3000 (#0)

GET / HTTP/1.1
Host: localhost:3000
User-Agent: curl/7.68.0
Accept: /

  • Mark bundle as not supporting multiuse
  • HTTP 1.0, assume close after body
    < HTTP/1.0 400 Bad Request
    <
    Client sent an HTTP request to an HTTPS server.
  • Closing connection 0

4. Error messages and/or full log output:

I have a local wordpress server (192.168.0.210) which is serving a page on port 80. I want to connect Caddy as a proxy for this. I will then expose the proxy via my firewall. I will then update the configuration to use the https/443 ports.

5. What I already tried:

I have tried rebuilding and various permutations of config. I just can’t get the reverse proxy to work.

I cannot get a response other than an HTTPS error.

I have searched and searched for some help with this.

6. Links to relevant resources:

Thank you!!!

If you configure your site address to localhost but make a request with an IP address, there’s a mismatch. Caddy is expecting to see localhost as the hostname, and if it doesn’t have that then it ignores the request.

Also, you made an HTTP request to an HTTPS server, as the curl response tells you. You’d need to use https:// rather than http://.

If you use :3000 as your site address instead of localhost:3000, Caddy will only listen on HTTP instead of HTTPS (because using a domain like localhost will activate Caddy’s Automatic HTTPS functionality), then you can do curl -v http://192.168.0.239:3000/ from whatever machine on your network.

Please read these instructions to know how to look at your logs:

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