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, ...
Get Nginx Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.