Configuring NGINX as a simple reverse proxy
In this recipe, we'll look at the basic configuration of a simple reverse proxy scenario. If you've read the first few chapters, then this is how NGINX was configured in front of PHP-FPM and similar anyway.
Getting ready
Before you can configure NGINX, you'll first need to ensure your application is listening on a different port than port 80
, and ideally on the loopback
interface, to ensure it's properly protected from direct access.
How to do it...
Here's our server
block directive to proxy all requests through to port 8000
on the localhost:
server { listen 80; server_name proxy.nginxcookbook.com; access_log /var/log/nginx/proxy-access.log combined; location / { proxy_pass http://127.0.0.1:8000; } }
How it works...
For all requests, the location
block directive is set to proxy all connections to a specified address (127.0.0.1:8000
in this instance). With the basic settings, NGINX doesn't manipulate any of...