alexta69 / metube

Self-hosted YouTube downloader (web UI for youtube-dl / yt-dlp)
GNU Affero General Public License v3.0
6.25k stars 390 forks source link

caddy-docker-proxy syntax #439

Open lockheed opened 4 months ago

lockheed commented 4 months ago

I got lost trying to convert caddy format

example.com { route /metube/* { uri strip_prefix metube reverse_proxy metube:8081 } }

to caddy-docker-proxy format

Anyone got this working or is willing to give it a shot?

PikuZheng commented 4 months ago

I'm not sure but it looks like

caddy: example.com
caddy.route: /metube/*
caddy.route.uri: strip_prefix metube
caddy.route.reverse_proxy: metube:8081
lockheed commented 4 months ago

Sorry, I should have mentioned I already tried the above and it did not work.

PikuZheng commented 4 months ago

Can you provide the complete compose yaml. I suspect the issue is metube's environments.

jgoguen commented 4 months ago

I have it working no problem.

compose.yaml

---
services:
  metube:
    image: ghcr.io/alexta69/metube:latest
    container_name: metube
    user: "1000:1000"
    environment:
      OUTPUT_TEMPLATE: "%(title)s [%(id)s].%(ext)s"
      OUTPUT_TEMPLATE_CHAPTER: "%(title)s - %(section_number)s %(section_title)s [%(id)s].%(ext)s"
      YTDL_OPTIONS: '{"writeinfojson": false, "windowsfilenames": true, "clean_infojson": true, "http_headers": {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15"}}'
    ports:
      - "8081:8081"
    volumes:
      - "/mnt/docker/metube:/downloads"
    labels:
      - com.centurylinklabs.watchtower.enable=true
    restart: unless-stopped

Caddyfile:

example.com:443 {
  redir /metube /metube/ permanent
  handle_path /metube/* {
    reverse_proxy 127.0.0.1:8081
  }
}
lockheed commented 4 months ago

@jgoguen you are talking about something else. You have it working with caddy and Caddyfile, I want to translate the Caddyfile into label structure to have it working with caddy-docker-proxy without Caddyfile.

@PikuZheng sure thing, here it is:

services:
  metube:
    image: ghcr.io/alexta69/metube
    container_name: metube
    environment:
      - 'YTDL_OPTIONS={"writesubtitles":true,"subtitleslangs":["en","pl","fr","-live_chat"],"updatetime":false,"postprocessors":[{"key":"Exec","exec_cmd":"chmod 0664","when":"after_move"},{"key":"FFmpegEmbedSubtitle","already_have_subtitle":false},{"key":"FFmpegMetadata","add_chapters":true}]}'
    volumes:
      - /z/metube:/downloads
    networks:
      - frontend
    labels:
        caddy: my.domain.com
        caddy.route: /metube/*
        caddy.route.uri: "strip_prefix metube"
        caddy.route.reverse_proxy: "* {{upstreams 8081}}"        
    restart: unless-stopped

networks:
  frontend:
    external: true
PikuZheng commented 4 months ago

docker log shows it's correct.

ts=1716332154.8123088 logger=docker-proxy msg=New Caddyfile caddyfile=my.domain.com {
    route /metube/* {
        reverse_proxy * 172.21.0.2:8081
        uri strip_prefix metube
    }
}

so it's the caddy's https issue i think.

lockheed commented 4 months ago

Doesn't work for me. I made sure caddy and metube are on the same network. Maybe metube log isn't right?

INFO:ytdl:waiting for item to download

Setting umask to 022

Creating download directory (/downloads), state directory (/downloads/.metube), and temp dir (/downloads)

Changing ownership of download and state directories to 1000:1000

Running MeTube as user 1000:1000

INFO:main:Listening on 0.0.0.0:8081

DEBUG:asyncio:Using selector: EpollSelector

INFO:ytdl:waiting for item to download

Setting umask to 022

Creating download directory (/downloads), state directory (/downloads/.metube), and temp dir (/downloads)

Changing ownership of download and state directories to 1000:1000

Running MeTube as user 1000:1000

INFO:main:Listening on 0.0.0.0:8081

DEBUG:asyncio:Using selector: EpollSelector

INFO:ytdl:waiting for item to download
PikuZheng commented 4 months ago

the log of metube looks correct but you should watch caddy-docker-proxy 's log

lockheed commented 4 months ago
my.domain.com {
    route /metube/* {
        reverse_proxy * 172.18.0.4:8081
        uri strip_prefix metube
    }
}