Listen to every domain and the ip on port 80, http

1. The problem I’m having:

Listen to every domain/ip on port 80, http

2. Caddy version:

v2.8.4

3. My complete Caddy config:

https://tomikjetu.me, https://www.tomikjetu.me {
        reverse_proxy http://localhost:3000
        route /api* {
                reverse_proxy http://localhost:4000
        }
}

https://widgetsgarden.com, https://www.widgetsgarden.com {
        reverse_proxy http://localhost:3100
        route /api* {
                reverse_proxy http://localhost:4100
        }

        route /analytics* {
                reverse_proxy http://localhost:4100
        }
}

https://ftp.tomikjetu.me {
        header {
                Access-Control-Allow-Origin *
                Access-Control-Allow-Credentials true
                Access-Control-Allow-Methods *
                Access-Control-Allow-Headers *
                defer
        }
        file_server browse {
        }
        root * /var/www/ftp
}

5. Links to relevant resources:

I have clients I want to host their websites on my server. I provide them with a guide how to add their dns records, but they can’t check it’s valid until I add the rule to my Caddyfile.
I’d like to add a fallback rule to port
:80 { respond "Hello form server" }

But this doesn’t seem to work as it’s automatically redirected to https.
I want it to work on any subdomains of tomikjetu, on the server ip and on any domains of my cients.

Example

Client links their dns to my server
They open their domain in the browser (http://whatever.com)
They see the response “Hello form server”
After they verified they’ve done it correctly I can later add a https rule.

Is this possible? Thank you!

Sounds like you want to disable the automatic HTTP->HTTPS redirects. In that case, configure auto_https disable_redirects in global options. Then it becomes your responsibility to perform that redirect for domains that you do want the redirect for.

But I don’t recommend this approach. The redirects are a good thing. I don’t think your approach of showing a fallback page is a good idea, because then any user who navigates to the domain in their browser even after setup will still see this fallback page (unless they type https://), unless you explicitly add the HTTP->HTTPS redirect.

Also, it sounds like you’re looking for Caddy’s On-Demand TLS: Automatic HTTPS — Caddy Documentation

3 Likes

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