A reverse proxy is useful for hosting multiple projects on one server. It allows you to connect multiple domains to your server, and serve a different application, depending on which domain was entered.
- One Server
- One Domain
We will use nginx in this tutorial:
sudo apt update sudo apt install nginx
Setting up the Firewall
To allow incoming connections to our nginx web server, we will need to adjust the firewall settings:
Writing our configuration
Create a file (using vim or nano) at /etc/nginx/sites-available/your.domain.com.conf and paste the following:
You will have to adjust two things in this config file to fit with your set up:
- Replace your.domain.com, with your domain/subdomain
- Replace 5555 with the port number of the app you want to proxy to
When you're done, save the file.
Enable our configuration
We're almost done, the only thing left to do is to enable the configuration.
sudo ln -s /etc/nginx/sites-available/your.domain.com.conf /etc/nginx/sites-enabled/your.domain.com.conf sudo systemctl reload nginx
Now that you've set up nginx, you should set up SSL to encrypt your traffic, which is a requirement for most applications.