Subdomain handling in URI

1. The problem I’m having:

I have just a general question if it’s possible with CaddyFile.

i have a subdomain test.example.com pointing to caddy server.

using CaddyFile i am doing

test.example.com {
reverse_proxy :8081
}

and it’s working perfectly.

Now i need more than one proxy running on the same server, instead of creating more subdomains on DNS side, i want it to handle at caddy side:

test-1.example.com {
reverse_proxy :8081
}

test-2.example.com {
reverse_proxy :8082
}

test-3.example.com {
reverse_proxy :8083
}

Please note that only test.example.com’s A record is pointing to caddyserver. So is it even possible using CaddyFile?

3. Caddy version:

2.6.4

4. How I installed and ran Caddy:

ubuntu/debian package

a. System environment:

Ubuntu 20.04

You must configure DNS to point to your server’s IP address, otherwise no browsers on the internet will know how to reach your server for those other domains.

You can use a wildcard subdomain like *.example.com in your DNS to make all subdomains resolve to your server.

hmmm,
well the issue is, my domains are like:

alpha.example.com → pointing to caddy_server_1
bravo.example.com → pointing to caddy_server_2

where alpha has further: alpha-1.example.com alpha-2.* same way with bravo-n etc…

if that is not possible then could I configure in this way?

alpha.example.com/one
      reverse_proxy :8081
alpha.exampe.com/two
      reverse_proxy :8082

?

You need to configure each subdomain individually, or use a wildcard. There’s no in-between with DNS.

To clarify, that question doesn’t have to do with webservers, it’s about how DNS works.

You could do *.alpha.example.com though.

See this article:

Thanks, I’ll try that at my domain provider first.

if that works then will that config work?

test1.alpha.example.com {
reverse_proxy :8081
}

test2.alpha.example.com {
reverse_proxy :8082
}

test3.alpha.example.com {
reverse_proxy :8083
}

?

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