Caddy reverse proxy

a year ago by WubbyGeth to c/selfhosted

I 'm trying to setup a caddy reverse proxy within Docker and I am following the guide in this YouTube video

https://www.youtube.com/watch?v=qj45uHP7Jmo but when I the run docker compose up -d command I get this error:

failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/home/Joe/container/caddy/Caddyfile" to rootfs at "/etc/caddy/Caddyfile": create mountpoint for /etc/caddy/Caddyfile mount: cannot create subdirectories in "/var/lib/docker/overlay2/49e15938cd9c418a331b963f6fbbd3bba726b28748113ee8d028f6adf034b525/merged/etc/caddy/Caddyfile": not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

I am a bit perplexed on what I am doing wrong so any advice would be appreciated!

roofuskit 7 points a year ago

Can you share your compose file? You should be able to paste into code blocks in a comment or your original post. It's likely you've yamld something wrong.

path: 0 15762047, hotness: undefined, score: 7, children: 1
funkajunk 9 points a year ago

Sounds like a bad prank show

YOU GOT YAML'D! πŸ€ͺ

path: 0 15762047 15762241, hotness: undefined, score: 9, children: 0
banshee 5 points a year ago
path: 0 15762479, hotness: undefined, score: 5, children: 3
WubbyGeth 2 points a year ago

I do but I am wondering if the syntax in my caddyfile is wrong.

I did get past my initial error thanks to this group but I cannot get to my portainer via host name still.

path: 0 15762479 15763066, hotness: undefined, score: 2, children: 2
Xanza 5 points a year ago

I do but I am wondering if the syntax in my caddyfile is wrong.

Caddy can format caddyfiles;

caddy fmt --overwrite /home/Joe/container/caddy/Caddyfile
caddy validate --config /home/Joe/container/caddy/Caddyfile --adapter caddyfile
path: 0 15762479 15763066 15765955, hotness: undefined, score: 5, children: 0
enemenemu 1 point a year ago

You can format it automatically

path: 0 15762479 15763066 15764327, hotness: undefined, score: 1, children: 0
WubbyGeth 4 points a year ago

Here is my YAMLD YAML haha

version: '3.3' networks: caddy: services: portainer: image: portainer/portainer-ce:latest container_name: portainer2 restart: unless-stopped security_opt: - no-new-privileges:true volumes: - /etc/localtime:/etc/localtime:ro - /var/run/docker.sock:/var/run/docker.sock:ro - /home/Joe/containers/portainer/portainer-data:/data networks: - caddy ports: - 9000:9000

caddy: image: caddy:latest restart: unless-stopped container_name: caddy ports: - 80:80 - 443:443 volumes: - /home/Joe/container/caddy/Caddyfile:/etc/caddy/Caddyfile - /home/Joe/container/caddy/site:/srv - /home/Joe/container/caddy/caddy_data:/data - /home/Joe/container/caddy/caddy_config:/config networks: - caddy volumes: caddy_data:

path: 0 15762612, hotness: undefined, score: 4, children: 2
HelloRoot 6 points a year ago

The error suggests that you're trying to mount a file (Caddyfile) onto a directory or vice versa. Let's debug this step by step.

Steps to Fix:

  1. Check if the path exists and is correct Run:

    ls -ld /home/Joe/container/caddy/Caddyfile
    
    • If it’s a directory, it should be a file instead.
    • If it doesn’t exist, create an empty one:
      touch /home/Joe/container/caddy/Caddyfile
      
  2. Ensure correct permissions

    chmod 644 /home/Joe/container/caddy/Caddyfile
    
  3. Check YAML Formatting
    Your docker-compose.yml seems to have incorrect indentation and improper quotes around version. Here's a fixed version:

    version: "3.3"
    
    networks:
      caddy:
    
    services:
      portainer:
        image: portainer/portainer-ce:latest
        container_name: portainer2
        restart: unless-stopped
        security_opt:
          - no-new-privileges:true
        volumes:
          - /etc/localtime:/etc/localtime:ro
          - /var/run/docker.sock:/var/run/docker.sock:ro
          - /home/Joe/containers/portainer/portainer-data:/data
        networks:
          - caddy
        ports:
          - 9000:9000
    
      caddy:
        image: caddy:latest
        restart: unless-stopped
        container_name: caddy
        ports:
          - 80:80
          - 443:443
        volumes:
          - /home/Joe/container/caddy/Caddyfile:/etc/caddy/Caddyfile
          - /home/Joe/container/caddy/site:/srv
          - /home/Joe/container/caddy/caddy_data:/data
          - /home/Joe/container/caddy/caddy_config:/config
        networks:
          - caddy
    
  4. Restart Docker and Try Again

    docker compose down
    docker compose up -d
    

If the error persists, check docker logs caddy for additional hints.

path: 0 15762612 15763067, hotness: undefined, score: 6, children: 1
badlotus 12 points a year ago

Seems like AI wrote this. And did a good job!

path: 0 15762612 15763067 15763829, hotness: undefined, score: 12, children: 0
funkajunk 4 points a year ago

I have always had trouble whenever I tried mounting files, and it seems that you're getting the same error, "not a directory".

Stick to mounting directories and you should be fine

/home/Joe/container/caddy:/etc/caddy

path: 0 15762206, hotness: undefined, score: 4, children: 0
enemenemu 3 points a year ago

I was successful in installing and using caddy directly on my host instead of podman (docker).

Edit: someone doesn't like that I succeeded at it ...

path: 0 15762604, hotness: undefined, score: 3, children: 0
WubbyGeth 1 point a year ago

Thank you everyone for your help!

I elected to start from scratch and use nginx and have come across another issue that I am hoping someone can shed some light on.

  • I've purchased a domain.
  • configured CloudFlare to use as my DNS.
  • set up a CNAME for my two test containers.
  • set up my SSL cert in nginx
  • forwarded the proper ports on my router for my test containers.
  • Configured two hosts. AudioBookShelf and Portainer

I can get to my Audiobookshelf perfectly from the web but when I try to reach my portainer it just re-directs to my audiobookshelf container.

When I disable audiobookshelf and attempt access my portainer I now get error code 521 website down. I am not sure what I misconfigured.

path: 0 15785743, hotness: undefined, score: 1, children: 0
muntedcrocodile -3 points a year ago path: 0 15762156, hotness: undefined, score: -3, children: 4
roofuskit 6 points a year ago

Caddy is growing in popularity and finding its ways into more and more tutorials. Traefik and Caddy seem to be found in more reverse proxy tutorials/docs than NPM anymore. Forget about SWAG these days.

path: 0 15762156 15762417, hotness: undefined, score: 6, children: 0
fatalicus 5 points a year ago

Because caddy has built in, and default enabled, SSL of all sites using letsencrypt, something nginx doesn't have from what I can see.

path: 0 15762156 15764896, hotness: undefined, score: 5, children: 1
muntedcrocodile 1 point a year ago

Nginx does not have default SSL but the example I've uploaded has its quite a simple setup and gives you far greater control and modularity.

path: 0 15762156 15764896 15765195, hotness: undefined, score: 1, children: 0
funkajunk 0 points a year ago

nginx >>>>>

path: 0 15762156 15762214, hotness: undefined, score: 0, children: 0
selfhosted
selfhosted

@lemmy.world

login for more options
61555
6650
5623

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

Detailed Rules Post

  1. Be civil.

  2. No spam.

  3. Posts are to be related to self-hosting.

  4. Don't duplicate the full text of your blog or readme if you're providing a link.

  5. Submission headline should match the article title.

  6. No trolling.

  7. Promotion posts require active participation, with an account that is at least 30 days old. F/LOSS without a paywall has exceptions, with requirements. See the rules link for details. Tags [CBH] or [AIP] are required, see the links in Rule 8 for details.

  8. AI-related discussions and AI-involved promotional posts have additional requirements for tagging, as noted in Rule 7 and the AI & Promotional Post Expanded Rules post, and find example disclosures here.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

go to feed...