Reputation: 334
I want to create a Minecraft server and I already have a server that runs multiple Minecraft servers.
I also have an OVH domain and I've created a subdomain with a wildcard.
I want to create subdomains to access each of my Minecraft servers.
For example, I have two Minecraft servers, one with port 25560 and the other with port 25561. My main domain is "example.com" and I want to connect to my first Minecraft server using "server1.example.com:25565", which would redirect to the server running on port 25560. Similarly, I want to connect to my second server using "server2.example.com:25565", which would redirect to the server running on port 25561.
I tried to create a configuration in NGINX Stream module but I can't use the server_name to specify a subdomain.
I think it's possible because I've seen many Minecraft servers with subdomains. What am I doing wrong?
my module-enable/mc.example.com.conf
stream {
server {
listen 25565;
server_name server1.example.com;
proxy_pass minecraft;
}
upstream minecraft {
server 127.0.0.1:25560;
}
server {
listen 25565;
server_name server2.example.com;
proxy_pass minecraft2;
}
upstream minecraft2 {
server 127.0.0.1:25561;
}
}
EDIT 20/01/2023:
So I tried something else
stream {
server {
listen 25565;
server_name server1.example.com;
proxy_pass 127.0.0.1:25560;
}
server {
listen 25565;
server_name server2.example.com;
proxy_pass 127.0.0.1:25561;
}
}
But I got this error:
"server_name" directive is not allowed here
Upvotes: 1
Views: 1100
Reputation: 1
You could either setup a BungeeCord server and let players switch servers from within the game or get a second public IP and handle it with another port forwarding. I don't see any more options here.
Upvotes: 0