Nginx Streams
I'm pretty new to Nginx and managing subdomains etc. and this doesn't exactly have something to do with Cloudflare but I'm not sure where else to ask.
This is my config for trying to setup minecraft servers:
My idea is to have n amound of CNAMEs and SRV records that all listen at
25565
(minecrafts default port) and forward to their respective subdomain on my server. that server then listens on said port 25565
and should forward it to the specific minecraft server depending on the subdomain.
e.g.:
alpha.example.com
> 192.168.178.2:27000
beta.example.com
> 192.168.178.2:27001
...
other.example.com
> 192.168.178.2:27000
(default should either be the first one or no connection at all)
currently everything coming in at 25565
resolves to the default being 192.168.178.2:27000
which isn't great.
my motivation being that I had a setup before where the client would have to specify different ports if it wasn't the default one like beta.example.com:25566
which I'd like to avoid.
Anyone have an idea how i could implement this/ where i could find more information on this topic?
Thanks in advance29 Replies
On another note, I was also thinking of reusing the CNAME records by creating new SRV records but for different ports, so that i can reuse names like
alpha.example.com
but listening on some port 12345
which I would then resolve similarly to minecraft to some other game server like ARK, but first id like to get it to work for minecraft. Is this possible though?If you create the correct SRV record, clients don't need to enter the port.
I don't see how what you've explained above would work.
How would a correct SRV record look like?
It would have the correct port
currently I have something like
_minecraft._tcp.alpha.example.com
On port 25565 targeting alpha.example.com
The SRV record tells minecraft what port the server on alpha is using
The port I enter in the SRV record is the one the server is using and not what the client will use to connect?
both are the same?
Hmm no because I have for example
alpha running on 27000
beta on 27001 etc
Yes?
But the user will always be incoming on 25565
So how do I link them correctly
no
why will the user connect to 25565?
because they just input the address without specifying the port, so they use the standard port of 25565
no
At least that’s what I’m hoping to achieve
thath's why you have an srv record
to tell minecraft which port to use
Hmm ok so I change the SRV to port 27000 for example
Then the user goes to alpha.example.com, without specifying the port, and my server is listening at 27000
Would this work?
yes
Interesting, didn’t know SRVs worked like that
Btw I called it _minecraft._tcp.alpha because I saw others do it, is that just a naming convention/ preference or is the name important?
for sub.example.com, minecraft checks for an srv on _minecraft._tcp.sub.example.com
Just to make sure, there’s no way I can route on my reverse proxy instead, routing depending on subdomain, I’d prefer only opening one port on my router if possible
no
not without plugins
because you don't know what subdomain someone used to connect
unfortunate
how feasible is installing/ using the plugins? though imma first try it with the SRV records real quick
installing? I doubt on that does exactly this exists, so you'd need to program it first.
ah lol
yeah ok fair enough
wow that actually worked with the SRVs, thank you!
now if i wanted to reuse the CNAME alpha.example.com id just need to create a new SRV on a different port and link that to some different game server, right?
or change the old srv^^
would both at the same time work? 👀
alpha.example.com in minecraft would go to the minecraft server and the same address would go to for example an ark server if i have two SRVs setup?
because if so thatd be pretty neat
yes
But I believe Ark doesn't support SRV records?
You can use the same subdomain for every game that supports srv records, but only one game that doesn't
ah fair, i didnt check if ark does but that makes sense
thanks so much for the help! you probably saved me hours if not days of trying to get this to work ^^;