A reverse proxy is an intermediary proxy service which takes a client request, passes it on to one or more servers, and subsequently delivers the server’s response to the client.
$ sudo apt install nginx
Let's say you have a service (like a docker container) on port 5000. You want to forward this to domain.com, http.
Then, we need to create a file within the /etc/nginx/sites-available
directory that contains the reverse proxy information.
reverse-proxy.conf
server {
listen 80;
server_name domain.com www.domain.com;
location / {
proxy_pass http://127.0.0.1:5000;
}
}
Once you’ve added the appropriate directives to your .conf
file, activate it by linking to /sites-enabled/
using the following command.
$ ln -s /etc/nginx/sites-available/reverse-proxy.conf /etc/nginx/sites-enabled/reverse-proxy.conf
Lastly, run an Nginx configuration test and restart Nginx.
$ service nginx configtest
$ service nginx restart