Setup caddy from docker compose

1. Output of caddy version:

caddy:2-alpine

2. How I run Caddy:

docker-compose up -d

a. System environment:

Ubuntu 20.04.4 LTS docker compose

b. Command:

docker-compose up -d

c. Service/unit/compose file:

version: '3'

services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: always
    environment:
      WEBSOCKET_ENABLED: "true"  # Enable WebSocket notifications.
      SIGNUPS_ALLOWED: "false"
    volumes:
      - ./vw-data:/data

  caddy:
    image: caddy:2
    container_name: caddy
    restart: always
    ports:
      - 80:80  # Needed for the ACME HTTP-01 challenge.
      - 443:443
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - ./caddy-config:/config
      - ./caddy-data:/data
      - ./test_code:/wdata
    environment:
      DOMAIN: "https://vault.example.com.ru"  
      EMAIL: "mail@mail.com"                 
      LOG_FILE: "/data/access.log"

d. My complete Caddy config:

test.example.com { 
  root * wdata 
  file_server
 
  tls {$EMAIL}
}

https://vault.example.com:443 {
  log {
    level INFO
    output file {$LOG_FILE} {
      roll_size 10MB
      roll_keep 10
    }
  }

  tls {$EMAIL}
  encode gzip

  # Notifications redirected to the WebSocket server
  reverse_proxy /notifications/hub vaultwarden:3012

  # Proxy everything else to Rocket
  reverse_proxy vaultwarden:80 {
       # Send the true remote IP to Rocket, so that vaultwarden can put this in the
       # log, so that fail2ban can ban the correct IP.
       header_up X-Real-IP {remote_host}
  }
}

3. The problem I’m having:

Hello! I apologize for my bad English and stupid questions. I’ve searched the forum but couldn’t find answers to my questions. I have a small VPS server running vault warden and using caddy as the recommended web server for the web interface. Everything started up and works great. But now I want to add a static site, I’m getting a 404 error when I try to add a single site, on the path “test_code” is caddy.html file, but I still get a 404 error. I can’t figure out how to solve this problem.

4. Error messages and/or full log output:

browser return 404 

5. What I already tried:

I don’t know what to do in this case…

6. Links to relevant resources:

Hi :wave:

Try adding the absolute path in your Caddyfile

Instead of

use

  root * /wdata
  file_server
2 Likes

Sorry it is so simple, why didn’t I figure it out? thank you

1 Like

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