Reverse proxy *.localhost not working in Firefox or Chrome

1. Output of caddy version:


2. How I run Caddy:

a. System environment:


b. Command:

docker compose up -d

c. Service/unit/compose file:

version: "3.7"

    image: caddy:latest
    container_name: caddy
    restart: unless-stopped
      - "80:80"
      - "443:443"
      - "443:443/udp"
      - /home/docker/caddy/Caddyfile:/etc/caddy/Caddyfile
      - /home/docker/caddy/site:/srv
    name: docker-net
    external: true

d. My complete Caddy config:

http://pihole.localhost {
        reverse_proxy pihole:80
http://portainer.localhost {
        reverse_proxy portainer:9000
http://router.localhost {
http://wap.localhost {

3. The problem I’m having:

Everything works beautifully in Safari.

Firefox redirects to https://.

Chrome doesn’t redirect to https:// but still doesn’t work.

4. Error messages and/or full log output:

Firefox gives unable to connect

Chrome gives 'connection refused'

curl -v http://pihole.localhost
*   Trying
* Connected to pihole.localhost ( port 80 (#0)
> GET / HTTP/1.1
> Host: pihole.localhost
> User-Agent: curl/7.79.1
> Accept: */*
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
< Date: Sun, 23 Oct 2022 07:00:16 GMT
< Server: Caddy
< Server: lighttpd/1.4.59
* Connection #0 to host pihole.localhost left intact

5. What I already tried:

I’ve tried private mode in Firefox. Clearing history. Installing on a different machine and not signing into Firefox sync and without installing extensions.

6. Links to relevant resources:

Your system might not be configured to resolve *.localhost to or ::1. Curl is reporting that it tries to connect to instead.

That’s not really a problem with Caddy or your browsers, you’ll need to figure out how to configure your system such that it does.

Your system might not be configured to resolve *.localhost to or ::1.

You’re right, but unless I’m missing something, how would that help? I ran that curl from a LAN device. It’s correctly forwarding it to the docker host at where it hits caddy via port mapping. If http://pihole.localhost resolved to, it would never make it to caddy in the first place, no?

If you were trying to use that to connect to another device, then you’re using the wrong domain.

localhost and *.localhost are supposed to resolve to or ::1, not to some other LAN IP address.

The “more correct” domain to use is for LAN use. You could use .local but that can cause issues because Apple devices use that for multicast.

1 Like

Ahh, that fixed the issue. I thought I had to use the .localhost domain.


1 Like

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