Caddyfile is Blank but Redirecting me to Different Page

1. Caddy version (caddy version):

istvan@istvan:~$ docker exec -it caddy caddy version
v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=

2. How I run Caddy:

I just setup a fresh copy of Caddy and seem everything is working fine as I don’t see anything in logs (----------------------------------------------------------------------ENVIRONM - Pastebin.com)

a. System environment:

I am running on Ubuntu 18.04 LTS on Docker. And here is my compose

b. Command:

N/A

c. Service/unit/compose file:

  caddy:
    image: hotio/caddy
    hostname: ${DOCKERHOSTNAME}
    ports:
      - 80:8080
      - 443:8443
    container_name: caddy
    cap_add:
      - NET_ADMIN
    environment:
      - PUID=${PGID}
      - PGID=${PUID}
      - TZ=${TZ}
    restart: unless-stopped
    volumes:
      - ${DOCKERCONFDIR}/caddy:/config

d. My complete Caddyfile or JSON config:

{
  http_port  8080
  https_port 8443
}

:8080 {
  log {
    output file /config/logs/access.log
  }
  root * /app/www
  file_server
}

3. The problem I’m having:

I installed a fresh copy of caddy and when I visit this page http://mydomain.com it redirects me to qbittorrent webui. As you can see I didnt set any reverse proxy yet on Caddyfile.

I already set my DNS records on Cloudflare so I am not sure if thats where I am doing wrong but (just to give you heads up) I was running swag/letsencrypt since last year and everything was working fine so DNS records should be okay.

4. Error messages and/or full log output:

I don’t see any errors in logs so I am not sure.

5. What I already tried:

I already forwarded 80, 443 external and 8080, 8443 internal on my router.

Please let me know if you need any more information. Thank you so much

6. Links to relevant resources:

And this is my folder structure
istvan@istvan:~$ ls -alh ~/.config/appdata/caddy/
total 32K
drwxrwxr-x 7 istvan istvan 4.0K Apr 5 07:50 .
drwxrwxr-x 9 istvan istvan 4.0K Apr 5 07:27 …
drwx------ 2 istvan istvan 4.0K Apr 5 07:27 caddy
-rw-rw-r-- 1 istvan istvan 135 Apr 5 07:27 Caddyfile
drwxrwxr-x 6 istvan istvan 4.0K Apr 5 07:36 fail2ban
drwxrwxr-x 2 istvan istvan 4.0K Apr 5 07:36 logs
drwx------ 2 istvan istvan 4.0K Apr 5 07:27 .step
drwxrwxr-x 2 istvan istvan 4.0K Apr 5 07:27 templates

Maybe the redirect was cached by your browser? Try using curl -v and see what happens.

Try inside the container?

Copying what I wrote on Discord:

Remove this stuff:

{
  http_port  8080
  https_port 8443
}

and change the docker-compose ports to:

    ports:
      - 80:80
      - 443:443

And I recommend using the official docker image for Caddy, not a third-party one: Docker Hub

There’s no good reason to use a third party one for this. It just complicates things. We can’t really give support for unofficial images.

1 Like

Thank you so much @francislavoie

All working fine and thanks for the explanation on discord.

Much appreciated

1 Like