Proxy to docker container is not working like expected

1. Caddy version (caddy version):

1.0.3

2. How I run Caddy:

Using the docker image abisoft/caddy:latest with docker-compose.

a. System environment:

CentOS Linux 7 (Core), Docker 20.10.7, Docker-Compose 1.29.2

b. Command:

Using docker-compose

c. Service/unit/compose file:

version: "3"

services:
    
  caddy:
    environment:
      - ENABLE_TELEMETRY=false
    image: abiosoft/caddy
    container_name: caddy_main
    ports:
      - 80:80
      - 443:443
    volumes:
    - ./data:/root/.caddy
    - ./Caddyfile:/etc/Caddyfile

networks: 
  default: 
    external: 
      name: website-network

The docker-compose of the container it should proxy to:

Click to expand!
version: '3.1'

services:

  ghost:
      image: ghost:latest
      restart: always
      container_name: ghost
      depends_on:
          - db
      environment:
          database__client: mysql
          database__connection__host: db
          database__connection__user: root
          database__connection__password: <password>
          database__connection__database: ghost
          url: https://blog.bremauer.cc
      volumes:
          - /opt/Ghost/content:/var/lib/ghost/content
  db:
      image: mysql:5.7
      restart: always
      environment:
          MYSQL_ROOT_PASSWORD: <password>
      volumes:
          - /opt/Ghost/mysql:/var/lib/mysql

networks: 
  default: 
      external: 
          name: website-network

d. My complete Caddyfile or JSON config:

bremauer.cc, www.bremauer.cc {
 	proxy / frontend:80
        header / {
                X-XSS-Protection "1; mode=block"
                X-Frame-Options SAMEORIGIN
                Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
                Referrer-Policy "no-referrer"
                Content-Security-Policy upgrade-insecure-requests
                Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=()"
        }
}

drone.bremauer.cc {
        proxy / drone_server
        header / {
                X-XSS-Protection "1; mode=block"
                X-Frame-Options SAMEORIGIN
                Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
                Referrer-Policy "no-referrer"
                Content-Security-Policy upgrade-insecure-requests
                Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=()"
        }
}

blog.bremauer.cc {
        proxy / ghost:2368
        header / {
                X-XSS-Protection "1; mode=block"
                X-Frame-Options SAMEORIGIN
                Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
                Referrer-Policy "no-referrer"
                Content-Security-Policy upgrade-insecure-requests
                Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=()"
        }
}

3. The problem I’m having:

Im a little bit lost on how to tackle this problem because the first proxy works great.
So basicly i have a container running a ghost blog server on port 2368.
Now i want to proxy all requests for blog.bremauer.cc to the container with the name “ghost”.
I did it the same way like i proxy the requests for bremauer.cc to the frontend container but somehow it does not work at all for this case.
Every time i try to open the website it automaticly redirects me to “ghost:2368” instead of proxying the requests accordingly.
Both containers (Caddy and Ghost) are inside the same docker network.

4. Error messages and/or full log output:

Request to the endpoint:


! No logs written for the request !

5. What I already tried:

Tried upgrading to Caddy V2 and adapting proxy paths and ports for the ghost container. Nothing worked so far.
I tried to curl to the ghost container from inside another container inside the network and that worked. So its not a Network/Not available problem.

6. Links to relevant resources:

Used the following tutorial as a base: Building a Caddy container stack for easy HTTPS with Docker and Ghost

We no longer support Caddy v1, it’s EOL.

Please elaborate. What did you try exactly? What config, what did you see in your logs, etc?

I just solved my problem by adding the transparent option to the specifify proxy.

blog.bremauer.cc {
        proxy / ghost:2368 {
                transparent
        }
        header / {
                X-XSS-Protection "1; mode=block"
                X-Frame-Options SAMEORIGIN
                Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
                Referrer-Policy "no-referrer"
                Content-Security-Policy upgrade-insecure-requests
                Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=()"
        }
}

1 Like

transparent is the default in Caddy v2.

Please upgrade. There’s no reason to continue using such old software.

1 Like

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