Nginx/ko

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

설치
꾸러미를 바로 설치하기 전에, 먼저 nginx에 대한 USE 플래그를 살펴보는 것이 좋습니다.

Expanded USE flags
Nginx uses modules to enhance its features. To simplify the maintenance of this modular approach, the nginx ebuild uses expanded USE flags to denote which modules should be installed.


 * HTTP related modules can be enabled through the  variable
 * Mail related modules can be enabled through the  variable
 * Third party modules can be enabled through the  variable

These variables need to be set in. Their descriptions can be found in and.

For example, to enable the  module:

Emerge
With the USE flags set, install :

Installation verification
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:

설정
nginx 설정은 파일에서 다룹니다.

단일 사이트 접근
다음 예제는 (PHP 같은) 동적 기능을 뺀 단일 사이트 접근을 보여줍니다.

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

PHP support
다음 줄을 추가하여 nginx 설정에서 PHP 지원을 활성화하도록 하십시오. 이 예제에서 nginx는 유닉스 소켓을 통해 PHP 프로세스와 정보를 교환합니다.

이 설정 과정을 지원하려면, PHP에서 FastCGI 프로세스 관리자 지원(php-fpm)과 빌드해야 하며, 이 지원 사항은  USE 플래그를 통해 처리할 수 있습니다:

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
다음 예제에서는 각각의 URL(이 경우 /nginx_status)에서 다음에 대해서만 접근을 허용하는 방법을 보여줍니다
 * 각각의 호스트(예: 192.0.2.1 127.0.0.1)
 * IP 네트워크(예: 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:

문제 해결
In case of problems, the following commands can help troubleshoot the situation.

설정 확인
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.

프로세스 실행 확인
Check if nginx processes are running:

범위 주소 및 포트 확인
nginx 데몬이 올바른 TCP 포트에 대한 응답을 기다리는지 확인하십시오(HTTP에 대해서는 80, HTTPS에 대해서는 443):

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.