A reverse proxy server acts as an intermediary between end users and another server. Websites and game servers are popular use cases for a reverse proxy, each offering benefits such as improved security, easier access, and protection.
In this guide, we’ll show you how to set up a general-purpose reverse proxy for websites, as well as one specifically for game servers.
To set up a reverse proxy, you need a Linux server to host your proxy. In this example, we’re using Ubuntu as the Linux distribution, but the installation steps are very similar for most Linux distributions.
Recommended VPS specs For a reverse proxy designed for game servers, we strongly recommend choosing higher network speeds—especially if your server has many players. Your VPS streams raw TCP/UDP directly between the client (player) and the game server. For a web proxy, basic specs with minimal upgrades are usually sufficient. :)
We recommend setting up the proxy with a domain that you own. For each subdomain you want to use, create an A DNS record (e.g. zapdocs.example.com) pointing to your Linux VPS IP address. Users will use this address to access your website or game server.
Once your Linux VPS is ready, you’ll need to connect to it. See our SSH Quick Start guide to learn how.
You’ll use Nginx to host the reverse proxy because it’s a high-performance and popular open-source web server.
After connecting to your VPS, install Nginx with this command:
sudo apt install nginx
After installation, you’ll need to adjust your firewall so the service is accessible from the internet. For this guide, we’ll use the UFW firewall, since Nginx registers as an app and makes the setup straightforward. For more information about the UFW firewall, see our Linux Security Tips guide.
If you’re using another firewall (e.g. Iptables), make sure to allow Nginx access to ports 80 and 443, which the service uses.
You can view the Nginx profiles with sudo ufw app list. Here, we’ll choose Nginx Full, which allows HTTP for testing and HTTPS for production.
sudo ufw allow 'Nginx Full'
You can now test whether the site is reachable in your browser. If the test page appears, you can continue with the guide.
http://[deine_serverip]
A reverse proxy for websites offers many benefits, such as forwarding requests to internal server resources like a Vaultwarden instance (without a port in the URL) or forwarding them to external content, which is useful for load balancing and protection.
One major advantage is that your server can handle requests from any number of sources or domains, unlike a single web server that only runs on port 80/443.
First, create an entry in the Nginx directory for the domain you selected earlier—usually a subdomain such as zapdocs.example.com in our example.
Before continuing, make sure you’ve created an A record pointing to your proxy server’s IP address. Without it, the domain and everything else won’t work properly.
Switch to the server block directory with:
cd /etc/nginx/sites-available/
Now create a new configuration file. We recommend using the domain name as the filename so it’s easy to find (e.g. zapdocs.example.com). Replace [your_filename] with your preferred filename.
sudo nano [your_filename]
The Nano editor will open. Paste the following template into it. Replace [your_domain] with the domain you want to proxy, and [your_target_server] with the target server you want to reach.
upstream targetServer {
# Füge hier den Zielserver ein, den du erreichen willst. Das kann sein:
# Interne "localhost" Weiterleitung (z.B. 127.0.0.1:9090)
# Externer Server (z.B. 103.146.43.52:9000)
server [your_target_server];
}
server {
listen 80;
listen [::]:80;
# Domain, die bedient werden soll (z.B. zapdocs.example.com)
server_name [your_domain];
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass_request_headers on;
proxy_http_version 1.1;
proxy_pass http://targetServer;
}
}
Once you’ve made all the changes, save the file with CTRL + X, confirm with Y, and press ENTER.
Now activate the server block by creating a symlink to the active directory:
sudo ln -s /etc/nginx/sites-available/[your_filename] /etc/nginx/sites-enabled/[your_filename]
Check the syntax with:
sudo nginx -t
If everything looks good, reload Nginx to apply the new configuration:
systemctl reload nginx.service
Now test in your browser whether your domain loads the content you specified as targetServer. If you run into any issues, check the logs with:
journalctl -f -u nginx.service
to find errors.
A reverse proxy for game servers offers many benefits, such as an extra layer of security and greater reliability through better protection and restricted access to the main server.
Most dedicated game servers work great with the raw TCP/UDP proxy you’ll set up here. A small minority of games, such as BeamMP, may have issues with VPNs and proxies—you’ll need to test each game.
For this, you’ll need the Nginx Stream module, which isn’t included in the standard Nginx installation.
sudo apt install -y libnginx-mod-stream
sudo dnf -y install nginx-mod-stream
Add a new stream block to the main nginx.conf file, where you define the upstream server and the port your proxy should be available on.
Open the file with:
sudo nano /etc/nginx/nginx.conf
Now add the following block. Replace [your_target_server] with the server to stream to, including the port (e.g. :30120 for FiveM). Replace [your_port_listener] with the port users should use to connect to the proxy.
stream {
upstream targetServer {
# Zielserver, den du erreichen willst (z.B. 103.146.43.52:30120)
server [your_target_server];
}
server {
# Port, der Verbindungen annimmt und weiterleitet (z.B. 30120)
listen [your_port_listener];
proxy_pass targetServer;
}
}
Nginx will listen on the specified port and forward all connections to the target server.
Save the file with CTRL + X, confirm with Y, and press ENTER.
Check the syntax with:
sudo nginx -t
If everything looks good, reload Nginx to apply the configuration:
systemctl reload nginx.service
Now test whether you can connect to your game server through the proxy domain. If you run into any issues, check the logs with:
journalctl -f -u nginx.service
We strongly recommend installing an SSL certificate for your domains so data is transmitted securely over HTTPS. See our Creating an SSL Certificate guide, which explains the entire process for requesting and automatically renewing SSL certificates.