Skip to main content

Proxying Dynmap with Nginx

This tutorial covers how to proxy your Dynmap server behind Nginx with a free SSL certificate from Let's Encrypt installed

You Will Need

  • A Minecraft server with Dynmap installed - see the previous page
  • Root access to your proxy server
info

This tutorial assumes we are using Ubuntu 22.04 as the server OS and UFW as our firewall. Let's get started!


Reverse Proxy Setup

Installing Nginx

First off, we need to install Nginx, Certbot and allow HTTP access

[email protected]:~$ sudo apt update && sudo apt install nginx python3-certbot-nginx ufw -y
...
[email protected]:~$ sudo ufw allow 'Nginx Full' && sudo ufw enable

Configuration File

Below is an example configuration file. Edit it and save it as /etc/nginx/sites-available/dynmap

# /etc/nginx/sites-available/dynmap
server {
server_name map.yourdomain.com # change me
listen 80;
location / {
proxy_pass http://localhost:8123/; # change me
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

Enable the site and restart Nginx:

[email protected]:~$ sudo ln -s /etc/nginx/sites-available/dynmap /etc/nginx/sites-enabled/dynmap
[email protected]:~$ sudo systemctl restart nginx

SSL Certificate Deployment

We should be able to access our proxied map: type http://map.yourdomain.com into your web browser - if the Dynmap webpage shows up then huzzah!
Now all we need to do is set up an SSL certificate to secure our Dynmap - it's easy as 1, 2, 3!

[email protected]:~$ sudo certbot --nginx --agree-tos --no-eff-email -m [email protected] -d map.yourdomain.com
...

With that, you should be done! Just to be sure, restart Nginx to apply the configuration changes.
Now we should be able to access our secured Dynmap - type https://map.yourdomain.com into your web browser - if no SSL errors show up and the padlock is present in the URL bar, then you're all done!