0

I want to redirect "subdomain.mydomain.com" to "subdomain.mydomain.com/file.pdf" using the Caddy reverse proxy docker image by lucaslorentz. How can I achieve this with my docker compose setup described in the following?

My docker-compose.yml file for caddy looks like this:

version: "3.7"

services:
  caddy:
    image: lucaslorentz/caddy-docker-proxy:ci-alpine
    container_name: caddy
    restart: always
    ports:
      - 80:80
      - 443:443
    environment:
      - CADDY_INGRESS_NETWORKS=caddy
      - CADDY_CONFIG=/etc/caddy/Caddyfile  # Set the path to the Caddyfile
    networks:
      - caddy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /srv/caddy:/data
      - ./Caddyfile:/etc/caddy/Caddyfile

networks:
  caddy:
    external: true

My docker-compose.yml file for the websever looks like this:

version: '3.7'

services:
  file-server:
    image: dashersw/spa-server
    container_name: file-server
    restart: always
    volumes:
      - ./file.pdf:/app/file.pdf:r
    networks:
      - default
      - caddy
    labels:
      caddy: subdomain.mydomain.com
      caddy.reverse_proxy: "{{upstreams 8080}}"

networks:
  caddy:
    external: true

And finally the Caddyfile:

subdomain.mydomain.com {
    reverse_proxy / file.pdf
}

I have verified that the Caddyfile gets correctly mounted in the container using the commands docker exec -it caddy sh and cat /etc/caddy/Caddyfile.

Also Caddy itself is working as I have other services running that use Caddy and are working.

Also the file is available actually available (at subdomain.mydomain.com/file.pdf).

As you can see I already tried this with a Caddyfile ( which was previously unfamiliar to me), but I was unsuccessful.

Maludo
  • 1
  • 1

0 Answers0