~/Nginx Proxy Pass Configuration Guide

Mar 9, 2019


To set up a proxy pass with Nginx, update your server config block from your Nginx configuration file. This allows you to route incoming traffic to a backend server.

A typical configuration looks like this

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
server {
    listen 80;
    server_name example.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Reload Nginx with

1
sudo nginx -s reload

This config forwards all traffic on example.com to a backend server on localhost:3000. Customize the URL as needed.

See official docs for more proxy directives.

Tags: [nginx] [proxy] [reverseproxy]