Use NGINX as a Reverse Proxy

A reverse proxy is a server that sits between internal applications and external clients, forwarding client requests to the appropriate server. While many common applications, such as Node.js, are able to function as servers on their own, NGINX has a number of advanced load balancing, security, and acceleration features that most specialized applications lack. Using NGINX as a reverse proxy enables you to add these features to any application.

Basic Configuration for an NGINX Reverse Proxy

server {
  listen 80;
  listen [::]:80;


  location / {
      proxy_pass http://localhost:3000/;
      proxy_buffering off; # optional
      proxy_set_header X-Real-IP $remote_addr; # optional
      proxy_set_header Host $host; # optional
sudo nginx -t
sudo nginx -s reload

How to set up Reverse Proxy in Apache/httpd

Install and enable apache2 proxy modules

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests
sudo systemctl restart apache2

proxies all requests (“/”) to a single backend:

ProxyPass "/"  ""

to point to the reverse proxy, instead of back to itself, the ProxyPassReverse directive is most often required:

ProxyPass "/"  ""
ProxyPassReverse "/"  ""

Only specific URIs can be proxied

ProxyPass "/images"  ""
ProxyPassReverse "/images"  ""


<VirtualHost *:80>

Documentroot /var/www/html/

ProxyPass "/"  ""
ProxyPassReverse "/"  ""