O'Reilly logo

Nginx Essentials by Valery Kholodkov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setting up Nginx as a reverse proxy

Nginx can be easily configured to work as a reverse proxy:

location /example {
    proxy_pass http://upstream_server_name;
}

In the preceding code, upstream_server_name is the host name of the upstream server. When a request for location is received, it will be passed to the upstream server with a specified host name.

If the upstream server does not have a host name, an IP address can be used instead:

location /example {
    proxy_pass http://192.168.0.1;
}

If the upstream server is listening on a nonstandard port, the port can be added to the destination URL:

location /example {
    proxy_pass http://192.168.0.1:8080;
}

The destination URL in the preceding examples does not have a path. This makes Nginx pass the request as is, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required