How does hypixel have their website and minecraft server on their root domain? (I would like to do something similar)
Hypixel.net is both their website and mc server adress.
Is it just that https is on port 443 and minecraft is on port 25565?
And if that is the case, can i do something similar by making a reverse proxy have two seperate server blocks for the one domain, with different ports?
The amount of confidently incorrect responses is exactly what one could expect from Lemmy.
First: TCP and UDP can listen on the same port, DNS is a great example of such. You’d generally need it to be part of the same process as ports are generally bound to the same process, but more on this later.
Second: Minecraft and website are both using TCP. TCP is part of layer 4, transport; whereas HTTP(S) / Minecraft are part of layer 7, application. If you really want to, you could cram HTTP(S) over UDP (technically, QUIC/HTTP3 does this), and if you absolutely want to, with updates to the protocol itself, and some server client edits you can cram Minecraft over UDP, too. People need to brush up on their OSI layers before making bold claims.
Third: The web server and the Minecraft server are not running on the same machine. For something that scale, both services are served from a cluster focused only on what they’re serving.
Finally: Hypixel use reverse proxy to sit between the user and their actual server. Specifically, they are most likely using Cloudflare Spectrum to proxy their traffic. User request reaches a point of presence, a reverse proxy service is listening on the applicable ports (443/25565) + protocol (HTTPS/Minecraft), and then depending on traffic type, and rules, the request gets routed to the actual server behind the scenes. There are speculations of them no longer using Cloudflare, but I don’t believe this is the case. If you dig their mc.hypixel.net domain, you get a bunch of direct assigned IP addresses, but if you tried to trace it from multiple locations, you’d all end up going through Cloudflare infrastructure. It is highly likely that they’re still leaning on Cloudflare for this service, with a BYOIP arrangement to reduce risk of DDOS addressed towards them overflow to other customers.
For their website, it has orange cloud enabled to proxy traffic through CF’s global CDN and DDOS protection service.
For their Minecraft server, they advertise mc.hypixel.net, but also have a SRV record for _minecraft._tcp.hypixel.net set for 25565 on mc.hypixel.net
The mc.hypixel.net domain has CNAME record for mt.mc.production.hypixel.io. which is flattened to a bunch of their own direct assigned IP addresses.
Traceroute towards those direct assigned IP addresses goes through Cloudflare infrastructure but final destination is obscured, just like their website, to protect them from DDOS attacks.
TCP and UDP can listen on the same port, DNS is a great example of such. You’d generally need it to be part of the same process as ports are generally bound to the same process
They don't even need to be the same process. I'm pretty sure that's just a common practice if something needs both protocols, but there's nothing stopping you from having a web server on TCP 443 and a VPN server on UDP 443. Ports are an abstraction brought by each protocol, they aren't in anyway related.
Minecraft can read a special DNS record type called SRV records. You can create a record like that to point Minecraft to a port that the server is running on. It doesn't even have to have the same ip as the webserver.
Does Bedrock support SRV records yet? I honestly haven't checked in a year or two, but I tried to use SRV records to host a survival game and creative game on different ports but found out it didn't quite support them yet where as Java edition did.
Maybe most smaller ones have hosted both things separately, e.g.. with a dedicated minecraft server hoster and a common website-building+hosting service, and don't want to run an extra server for a proxy just for this.
With bigger servers (eg. Hypixel, 2b2t) or selfhosted servers (eg. mine), everything is on the same physical (or virtual) machine anyway and therefore everything has the same address, so you wouldn't even need a proxy.
Don't forget, you can also use SRV records to point a domain to another target, where you can also omit the port number. So connecting to server.org say, can point to mc.server.org:25565 under the hood.
This prolly isn't what hypixel are doing as everything's likely on the same network and their router/firewall is just forwarding traffic onto different machines, but SRV is one way to redirect a minecraft connection (and you could combine the technique with subdomains).
You cannot specify ports in a DNS A or AAAA record. www.example.com cannot resolve to 1.2.3.4:443 and app.domain.com cannot resolve to 1.2.3.4:5555
If the application (be it a game or whatnot) supports it, SRV records can identify a port for a hostname. So, you could have minecraft1.domain.com and an SRV record to specify port 25565, and minecraft2.domain.com SRV 25566.
This means you can have multiple Minecraft servers with the same IP address, but you won’t need to give people the port numbers to remember; the hostname allows the game to look up the port via the SRV record.
This is great for selfhosters because we generally only get one IP (until they rollout IPv6; probably half the reason they don’t)
I didn't say to specify a port in the DNS. I just said that it is a way that we can resolve a resource.
In the case of ports we'd configure it through whatever webserver (Apache, nginx, traefik, whatever) configs necessary on that machine. The DNS in this scenario would only be for the machines IP where our webserver then routes traffic to different ports.