Nginx/tr

nginx ufak, güçlü ve yüksek performanslı bir web/ters proxy (reverse proxy) sunucu yazılımıdır. Apache ve lighttpd gibi popüler web sunucu yazılımları için iyi bir alternatiftir.

Kurulum
paketini kurmadan önce, kullanabildiği USE bayraklarına göz atalım.

Genişletilmiş USE bayrakları
Nginx yeteneklerini artırmak için modülleri kullanır. Bu yaklaşımın faydalarını kullanmak için kurulumu sırasında hangi modüllerin kullanılacağını bazı USE setleri ile ayarlayabilirsiniz.


 * HTTP ile ilgili modüller  değişkeniyle,
 * E-posta özellikleri ile ilgili modüller  değişkeniyle,
 * Diğer üçüncü parti modüller de  değişkeni ile aktifleştirilebilir.

Bu değişkenler dosyasında tanımlanmalıdır. Detaylı açıklamaları ve  adreslerinde bulunabilir.

Örneğin  modülünü etkinleştirmek için:

Emerge
USE bayraklarıı ayarladıysanız, paketini kurun:

Kurulumun onaylanması
The nginx package installs a init service script allowing administrators to stop, start, or restart the service. Run the next command to start the nginx service:

To verify that nginx is properly running, point a web browser to the http://localhost address or use a command-line web tool like curl:

Configuration
The nginx configuration is handled through the file.

Single site access
The following example shows a single-site access, without dynamic capabilities (such as PHP).

Multiple site access
It is possible to leverage the  directive to split the configuration in multiple files:

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

To support this setup, PHP needs to be build with FastCGI Process Manager support (php-fpm), which is handled through the  USE flag:

Rebuild PHP with the  USE flag enabled:

Review the configuration and add following line:

Set the timezone in the php-fpm file. Substitute the  text in the FileBox below with the appropriate timezone information:

Start the php-fpm daemon:

Add php-fpm to the default runlevel:

Reload nginx with changed configuration:

IP address access list
The next example shows how to allow access to a particular URL (in this case /nginx_status) only to
 * certain hosts (e.g. 192.0.2.1 127.0.0.1)
 * and IP networks (e.g. 198.51.100.0/24)

Basic authentication
nginx allows limiting access to resources by validating the user name and password:

The file can be generated using:

TLS support
It is warmly suggested to support only TLS and disable known insecure ciphers.

The ebuild provides stock self signed certificates in

Forward secrecy
The diffie-hellman certificate can be created using openssl:

Third party modules
Download third party module source and move it to. Manually compile the selected Nginx module, then add the following line to :

Rebuild nginx with the third party module enabled:

OpenRC
Start nginx:

Stop nginx:

Add nginx to the default runlevel:

Restart the nginx service:

Troubleshooting
In case of problems, the following commands can help troubleshoot the situation.

Validate configuration
Verify that the running nginx configuration has no errors:

By running nginx with the  option, it will validate the configuration file without actually starting the nginx daemon.

Verify processes are running
Check if nginx processes are running:

Verify bound addresses and ports
Verify nginx daemon is listening on the right TCP port (such as 80 for HTTP or 443 for HTTPS):

External resources

 * http://nginx.org/en/docs/beginners_guide.html - A nginx</tt> beginner's guide. Helpful for those who do not know much about nginx</tt>.
 * http://nginx.com/resources/admin-guide/ - The ngnix Admin guide. Helpful for web administrators who have been working in the field.
 * http://wiki.nginx.org/Main - nginx Wiki.
 * https://github.com/h5bp/server-configs-nginx - H5BP nginx config.