Pi-hole on cloud with docker and caddy

I am trying to setup Pi-hole on a DO droplet with caddy and docker. But I can't access the webui.

docker-compose.yml

version: "3"

# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    # For DHCP it is recommended to remove these ports and instead add: network_mode: "host"
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      # - "67:67/udp" # Only required if you are using Pi-hole as your DHCP server
      - "3148:80/tcp"
    environment:
      TZ: 'Asia/Kolkata'
      WEBPASSWORD: 'password'
      DNSMASQ_LISTENING: 'all'
      VIRTUAL_HOST: 'pihole.mydomain.com'
    # Volumes store your data between container upgrades
    volumes:
      - './etc-pihole:/etc/pihole'
      - './etc-dnsmasq.d:/etc/dnsmasq.d'
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    # cap_add:
    # 	- NET_ADMIN # Required if you are using Pi-hole as your DHCP server, else not needed
    restart: unless-stopped
    networks:
      - com

networks:
  com:
    external: true

Caddyfile:

pihole.mydomain.com {
	redir / /admin
	reverse_proxy pihole:3148
}

Caddy docker compose file

version: "3.7"

networks:
    com:
        external: true
    internal:
        external: false
        driver: bridge

services:
    caddy:
        container_name: caddy
        image: caddy:2-alpine
        restart: unless-stopped
        ports:
            - "80:80"
            - "443:443"
            - "443:443/udp"
        volumes:
            - ./:/etc/caddy
            - ./data:/data
            - ./config:/config
        networks:
            - com
            - internal

This is the error from Caddy
caddy | {"level":"error","ts":1670595087.4591758,"logger":"http.log.error","msg":"dial tcp 172.18.0.3:3148: connect: connection refused","request":{"remote_ip":"202.88.249.66","remote_port":"57651","proto":"HTTP/3.0","method":"GET","host":"pihole.mydomain.com","uri":"/admin/","headers":{"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"],"Priority":["u=0, i"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.2 Safari/605.1.15"],"Accept-Language":["en-IN,en-GB;q=0.9,en;q=0.8"],"Accept-Encoding":["gzip, deflate"]},"tls":{"resumed":false,"version":0,"cipher_suite":0,"proto":"","server_name":""}},"duration":0.000771718,"status":502,"err_id":"yddjsz6gq","err_trace":"reverseproxy.statusError (reverseproxy.go:1272)"}

Any help is appreciated