NGINX as a Reverse Proxy
[ 80 ]
location @appserver {
proxy_pass http://127.0.0.1:8080;
}
}
The memcached_pass directive uses the $memcached_key variable to make the key
lookup. If there is no corresponding value (error_page 404), we pass the request
on to localhost, where there is presumably a server running that will handle this
request and insert a key/value pair into the memcached instance.
FastCGI upstream servers
Using a FastCGI server is a popular way to run PHP applications behind an NGINX
server. The fastcgi module is compiled in by default, and is activated with the
fastcgi_pass directive. This enables NGINX to speak the FastCGI protocol with one
or more upstream servers. We define a set of FastCGI upstream servers as follows:
upstream fastcgis {
server 10.0.200.10:9000;
server 10.0.200.20:9000;
server 10.0.200.30:9000;
}
And pass connections to them from the root location:
location / {
fastcgi_pass fastcgis;
}
This is a very minimalist configuration to illustrate the basics of using FastCGI.
The fastcgi module contains a number of directives and configuration possibilities,
which we will discuss in Chapter 6, The NGINX HTTP Server.
SCGI upstream servers
NGINX can also speak the SCGI protocol by using its built-in scgi module.
The principle is the same as for the fastcgi module. NGINX communicates
with an upstream server indicated with the scgi_pass directive.