Nginx

nginx is a robust, small and high performance web server and reverse proxy server. It is a good alternative to the popular available web servers like Apache and lighttpd.

Installation
Install :

USE flags
Add nginx to the default runlevel:

Configuration
The nginx configuration is handled by. Example 1 shows a single-site access, without dynamic capabilities (such as PHP).

Start nginx:

Verify nginx is running and responding as configured above:

Enabling PHP support
Add following lines to your nginx configuriation to enable PHP support. In this example nginx is exchanging information with the PHP process via a UNIX socket.

Additionally it is needed to build PHP with FastCGI Process Manager (php-fpm) support enabled. Add the fpm USE flag to the package:

Rebuild php with the new USE flag enabled.

Review the configuration, add following line:

Start the php-fpm daemon:

Add php-fpm to the default runlevel

Reload nginx with changed configuration

IP access list
Example 4 shows how to allow access to a particular site /nginx_status only to IP addresses are in CIDR notation, see definition example below:
 * certain hosts f.e. 192.0.2.1 127.0.0.1
 * and IP networks 198.51.100.0/24

Troubleshooting
Get general information using following troubleshooting commands.

Verify the running nginx configuration has no errors, nginx will only test -t the configuration without starting the process:

Check if the nginx process is running:

Verify nginx daemon is listening on TCP port 80:

External resources

 * nginx Wiki