Minecraft: Open solo world to internet

Minecraft has a feature named «Open to LAN», which allows players in your network to connect to your world, all without the hassle of setting up a server.

But what if you wanted to open it to the Internet ?

Using SSH reverse tunnel

You will need a linux server with a public IP address.

First, enable GatewayPorts yes in /etc/ssh/sshd_config and restart SSH with systemctl restart sshd

Then, open your solo world to LAN. I recommend to choose a port yourself, like 1234.
Start the tunnel with

ssh -R 0.0.0.0:25565:localhost:1234 user@host

This will forward traffic from the port 25565 of your Linux server to the port 1234 of you PC.

Sharing with Bedrock Edition

The next step is to share your solo world with friends playing on Bedrock Edition (available on mobile).

Using GeyserMC, we can forward Bedrock players to a Java edition server. You need the standalone version, it's a JAR that creates its config on the first startup like the minecraft server.

bedrock:
  port: 19132
  clone-remote-port: false
remote:
  address: 127.0.0.1
  port: 1234

You might need to play around with online/offline login options between Bedrock and Java