<-- Back to the main page. 🐱

Set up a Reverse Proxy for Pl3xMap using Nginx.

👋 Welcome back to my little corner on the Internet.

2021.09.08 | KoxSosen

Today we are going to learn how to set up a Reverse Proxy for Pl3xMap using Nginx. It's very easy :p

First of all, let's decide if you really need a Reverse Proxy. Pl3xMap already has a great guide for Nginx if you are planning on serving the Pl3xMap website directly. 
You can find that here.

This guide is for those, who can't really directly serve the Pl3xMap website files from the web server, such as if you are running your server using a shared host, or in Pterodactyl, or you have other limitations.

Let's get to work! You'll need:



1. Enable the inbuilt Pl3xMap web server.

Navigate to the config.yml file, which can be found in /path/to/server/plugins/Pl3xMap/. Set the enabled: option to true under internal-webserver:. ⚠️ Warning: Exposing the website backend directly to the internet, without ssl is a security risk. If you have the option to use a local address use that. ( like localhost, 127.0.0.1, or the containers private IP if using docker )

2. Install Nginx.

Let's install Nginx. Run the commands from the official Nginx site, which you can find here.

3. Configure Nginx.

The Nginx configuration directory in Debian based systems in most cases is /etc/nginx/. Play close attention to the , and other configuration files. Adjust values to your liking. mikroskeem already has a great config repository which you can find here.

4. Open the web server ports.

Make sure that port 80 ( for forwarding traffic to 443 ), and port 443 (for ssl) is open for in and out traffic.

5. Set up a Reverse Proxy.

The important step, why we're all here. First of all, let's crate a virtual host: sudo nano /etc/nginx/sites-avaliable/YOUR_DOMAIN Replace the block with whatever editor you use. nano is easy to beginners, vim or nvim is very handy. Same with the block. An example of this command goes as follows: sudo nano /etc/nginx/sites-avaliable/map.hahota.net You just created a virtual host! Great! Time to add the reverse proxy config. Feel free to copy & paste: server { listen 80; # Listen on port 80. server_name map.your.domain; # REPLACE with your domain location / { proxy_pass http://127.0.0.1; # REPLACE with the the ip you configured in pl3xmap. } } Save and exit. If using nano press Ctrl+o, and Ctrl+x, if using vim type :x, or ZZ. If you want to get familiar with vim give vimtutor a go.

6. Enable the site.

Now we are going to set up a symlink to activate the site: sudo ln -s /etc/nginx/sites-available/map.your.domain /etc/nginx/sites-enabled/ Make sure to replace the map.your.domain block with your domain. This step symlinks the virtual host config file to the enabled sites directory, activating the site.

7. Setup a DNS (Domain Name System) record.

We're getting close! Navigate to your registrars site, and log in. If you haven't gotten a domain yet, I'd recommend using Porkbun. Find the option to manage DNS. Add a new A record, like so: Make sure to replace the name with your preferred record name, and the IPv4 address with your servers public IPv4 address. Click add, and wait for it to propagate. 🎉 Enter the subdomain in your browser, and you should see the map! Wait! Don't close this yet! You haven't configured SSL!

8. Set up SSL.

There are multiple ways you can obtain an SSL certificate for free. One of them is certbot. Install certbot: sudo apt get update && sudo apt install python3-certbot-nginx Obtain the certificate: sudo certbot --nginx -d your_domain Make sure to replace the your_domain block with your domain, and choose the option to redirect http traffic to https. ⚠️ Warning: If you are using Cloudflare, and you have the Cloudflare proxy enabled, please see this guide.

9. Enjoy!

Navigate to https://map.your.domain/, and enjoy your new map! 😄 Closing thoughts: Thank you for reading my article! If you have any questions, or you found something about this article that is worth mentioning, feel free to add me on Discord at Simon.#4921. Have a nice day! ⚠️ Warning: Edit on 2022.01.16: This post was originally published on Sep 8. 2021, and got migrated to the self written instance today. Reading thru it 4 months later, there is a bunch of stuff I'd do differently now, but err, leaving this here for the history.

Copyright (C) KoxSosen

The content on this page is licensed under the GNU AGPL v3 license.

Find us on GitHub.