In this guide, we will walk you through the process of hosting a Godot server on a Linux server. This will allow you to run multiplayer games and interactive applications powered by the Godot game engine.
Before we start, make sure you have the following prerequisites:
First, export your Godot server project to a Linux-compatible .pck file.
Transfer the .pck file to your Linux server. You can use Filezilla or any other file transfer method you are comfortable with.
Download the correct version of Godot server binary for Linux :
curl -O -L https://github.com/godotengine/godot/releases/download/3.5.1-stable/Godot_v3.5.1-stable_linux_server.64.zip
If you don’t have unzip installed, you can do so with:
sudo apt install unzip
Unzip the downloaded Godot server:
unzip Godot_v3.5.1-stable_linux_server.64.zip
Test your Godot server using the .pck file and check if it’s running:
./Godot_v3.5.1-stable_linux_server.64 --main-pack linux.pck
Install the Nginx web server on your Linux server:
sudo apt install nginx
Create a symbolic link to your Nginx site configuration:
ln -s /etc/nginx/sites-available/example.xyz /etc/nginx/sites-enabled/
Edit your Nginx site configuration file:
-Check your port first-
nano /etc/nginx/sites-available/example.xyz
server {
listen 80;
server_name example.xyz; # Replace with your domain or server IP
location / {
default_type text/html;
return 200 'Hello Gamers!';
}
location /game {
proxy_pass http://localhost:8080/; # Redirect requests to your application
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Ensure that your Nginx configuration points to your Godot server.
Check your Nginx configuration for syntax errors:
sudo nginx -t
Reload Nginx to apply the new configuration:
sudo systemctl reload nginx
Install Certbot and the Nginx plugin for Let’s Encrypt:
sudo apt install certbot python3-certbot-nginx
Obtain an SSL certificate for your domain (replace example.xyz with your domain):
sudo certbot --nginx -d example.xyz
Your Godot server should now be up and running securely with HTTPS.
To confirm that your Godot server is working as expected, you can use a WebSocket testing tool like the “Pie Socket” extension in your browser. Follow these steps: