Reverse proxy to domain keeps loading

1. Caddy version (caddy version):

2.4.6

2. How I run Caddy:

I run Caddy inside a docker container on a VM

a. System environment:

Docker 20.10.10 running on Ubuntu 20

b. Command:

I use the Docker container

c. Service/unit/compose file:

version: "3.7"

services:
  caddy:
    container_name: caddy
    build: .
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - $PWD/Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config

volumes:
  caddy_data:
    external: true
  caddy_config:

d. My complete Caddyfile or JSON config:

somedomain.com {
	reverse_proxy http://<my-server-ip>:3000
}

test.someotherdomain.dev {
	reverse_proxy https://somedomain.com
}

3. The problem I’m having:

My DNS record for somedomain.com points to my-server-ip. Opening this domain directly works just fine. I also have a CNAME record test.someotherdomain.dev pointing to somedomain.com, opening this in my browser shows nothing and the loading icon of the browser keeps spinning. I know I can just use my-server-ip directly in the reverse-proxy directive for test.someotherdomain.dev but I want to have several of these test.someotherdomain.dev pointing to somedomain.com and only have to change my ip in one place and while showing test.someotherdomain.dev showing in the address bar.

4. Error messages and/or full log output:

No errors other than the browser loading

5. What I already tried:

I tried rewriting the Host header but that changes the URL in the address bar to somedomain.com. I want the address bar to still show test.someotherdomain.dev

6. Links to relevant resources:

You could just do this, I think, if it’s what I think you’re trying to do:

somedomain.com, test.someotherdomain.dev {
	reverse_proxy http://<my-server-ip>:3000
}

Much simpler than trying to chain them together.

1 Like

I believe the reverse_proxy line could even just be reverse_proxy <my-server-ip>:3000 since HTTP is the default for upstreams. :+1: