Multiple web servers with BYOD(Bring your own domain)

Hello, currently I own or heavily manage multiple services, however we did a server transition and the issue with this is I need to redo everything. The caddy config im having issues figuring out, however i have split it into multiple configs like this, each with their own on demand TLS server and more. Im running into issues with SSL not being given for my servers. I reach my users by allowing them to attach their own domains to my servers so they may have their own copy. Here is one of my example configurations.

Configuration:

{
    email <email>
    on_demand_tls {
        ask http://localhost:5555
    }
}

# Space 
<ip> {
    tls {
        on_demand
    }
    @wisp {
        path /wisp/
    }

    reverse_proxy @wisp localhost:4040

    reverse_proxy http://localhost:6060
    encode gzip
}

PM2 - Caddy logs

root@space:~/caddyfiles# pm2 logs 5
[TAILING] Tailing last 15 lines for [5] process (change the value with --lines option)
/root/.pm2/logs/caddy4space-out.log last 15 lines:
/root/.pm2/logs/caddy4space-error.log last 15 lines:
5|caddy4sp | {"level":"info","ts":1728340981.2378995,"msg":"using config from file","file":"space.caddyfile"}
5|caddy4sp | {"level":"info","ts":1728340981.2387748,"msg":"adapted config to JSON","adapter":"caddyfile"}
5|caddy4sp | {"level":"warn","ts":1728340981.2387884,"msg":"Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies","adapter":"caddyfile","file":"space.caddyfile","line":2}
5|caddy4sp | {"level":"info","ts":1728340981.2391982,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//127.0.0.1:2019","//localhost:2019","//[::1]:2019"]}
5|caddy4sp | {"level":"info","ts":1728340981.2392948,"logger":"http.auto_https","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
5|caddy4sp | {"level":"info","ts":1728340981.2393022,"logger":"http.auto_https","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
5|caddy4sp | {"level":"info","ts":1728340981.2393682,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00059b580"}
5|caddy4sp | {"level":"info","ts":1728340981.2395751,"logger":"http.log","msg":"server running","name":"remaining_auto_https_redirects","protocols":["h1","h2","h3"]}
5|caddy4sp | {"level":"info","ts":1728340981.2395947,"logger":"http","msg":"enabling HTTP/3 listener","addr":":443"}
5|caddy4sp | {"level":"info","ts":1728340981.239723,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
5|caddy4sp | {"level":"info","ts":1728340981.2397282,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["104.243.38.145"]}
5|caddy4sp | {"level":"info","ts":1728340981.2398345,"msg":"autosaved config (load with --resume flag)","file":"/root/.config/caddy/autosave.json"}
5|caddy4sp | {"level":"info","ts":1728340981.2398393,"msg":"serving initial configuration"}
5|caddy4sp | {"level":"info","ts":1728340981.2569785,"logger":"tls","msg":"storage cleaning happened too recently; skipping for now","storage":"FileStorage:/root/.local/share/caddy","instance":"2cdb736c-155d-4723-a2b4-e51f919577a5","try_again":1728427381.2569761,"try_again_in":86399.99999964}
5|caddy4sp | {"level":"info","ts":1728340981.2570758,"logger":"tls","msg":"finished cleaning storage units"}

How can I make it so it’ll serve and assign different things to any domain connected to the IPs based on what IP it is, as I know bind isn’t a thing anymore. Also I will be serving more than one thing, so the ability to make it work with any domain based on IP would be wonderful.

bind isn’t a thing anymore? I thought it was still a thing. Is it unsuitable for your use case?

Rather than an <ip> site address, maybe you want a catch-all https:// site address so it can serve arbitrary hostnames?

It’s hard to make guesses at exactly what kind of architecture you have or want to set up, so I can’t really give you anything other than vague responses.

If you fill out the help topic post template and give us an example of a request you’re making, how you want it to be routed, and how it’s failing for you currently, we can help you get a good result much more effectively.

1 Like

thats what i originallyy tried, however i cant get it to connect to my reverse proxies based on IP without something like bind.

i tried to fill it out, it not really me having an error, its more of a how do i properly do this?

Are you trying to avoid using bind for some reason?

:point_up:

This Caddyfile directive. Sorry to be blunt, but you haven’t actually answered - is bind not suitable for your use case for some reason?

1 Like

it says that the module isn’t installed, and when I figure out how to install it, everything i can find says its deprecated

Can you post your Caddyfile and logs?

Where does it say it’s deprecated, exactly?

1 Like

everything i can find about getting bind working says its outdated.

Where, though? Can you link me something? I genuinely don’t know about that and can’t find anything with a search.

Can you paste the log output for that? And what your Caddyfile was when you got that message?

You shouldn’t have to install it, it’s a core component, and it worked when I tested it.

1 Like

i have changed the caddy file for this to use bind, to get the errors thrown out here:

/root/.pm2/logs/caddy4space-out.log last 15 lines:
/root/.pm2/logs/caddy4space-error.log last 15 lines:
5|caddy4sp | Error: adapting config using caddyfile: getting matcher module 'bind': module not registered: http.matchers.bind
5|caddy4sp | {"level":"info","ts":1728384283.191816,"msg":"using config from file","file":"space.caddyfile"}
5|caddy4sp | Error: adapting config using caddyfile: getting matcher module 'bind': module not registered: http.matchers.bind
5|caddy4sp | {"level":"info","ts":1728384283.2375488,"msg":"using config from file","file":"space.caddyfile"}
5|caddy4sp | Error: adapting config using caddyfile: getting matcher module 'bind': module not registered: http.matchers.bind
5|caddy4sp | {"level":"info","ts":1728384283.2773087,"msg":"using config from file","file":"space.caddyfile"}
5|caddy4sp | Error: adapting config using caddyfile: getting matcher module 'bind': module not registered: http.matchers.bind
5|caddy4sp | {"level":"info","ts":1728384283.3178966,"msg":"using config from file","file":"space.caddyfile"}
5|caddy4sp | Error: adapting config using caddyfile: getting matcher module 'bind': module not registered: http.matchers.bind
5|caddy4sp | {"level":"info","ts":1728384283.3571484,"msg":"using config from file","file":"space.caddyfile"}
5|caddy4sp | Error: adapting config using caddyfile: getting matcher module 'bind': module not registered: http.matchers.bind
5|caddy4sp | {"level":"info","ts":1728384283.3908587,"msg":"using config from file","file":"space.caddyfile"}
5|caddy4sp | Error: adapting config using caddyfile: getting matcher module 'bind': module not registered: http.matchers.bind
5|caddy4sp | {"level":"info","ts":1728384283.431194,"msg":"using config from file","file":"space.caddyfile"}
5|caddy4sp | Error: adapting config using caddyfile: getting matcher module 'bind': module not registered: http.matchers.bind

My caddyfile

{
    email not.amplify@night-x.com
    on_demand_tls {
        ask http://localhost:5555
    }
}

# Space 
https:// {
    tls {
        on_demand
    }
    @space {
        bind 104.243.38.145
    }
    @wisp {
        path /wisp/
    }

    reverse_proxy @wisp localhost:4040

    reverse_proxy @space http://localhost:6060
    encode gzip
}

Bind is not a matcher, you can’t use it like this. It’s a Caddyfile directive in its own right.

Check the examples at https://caddyserver.com/docs/caddyfile/directives/bind#examples, especially the last one showing you how to use it with multiple sites.

1 Like

thank you. i have it partially figured out, the only issue is my second caddy file will not shown, I am addressing it.

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