New FAMILUG

The PyMiers

Wednesday 23 October 2013

NGINX beginner

NGINX là gì?
nginx [engine x] is an HTTP and reverse proxy server, as well as a mail proxy server, written by Igor Sysoev.
là một HTTP/reverse proxy/mail proxy server được viết để giải quyết bài toán C10K, hiện tại là một trong 2 HTTP server phổ biến nhất trên nền UNIX-like OSes. (theo http://wiki.nginx.org/Main )

Làm thế nào để trở thành một NGINX beginner?
Có nhiều cách, sau đây là 1 cách vớ vẩn nhất:
- Cài nginx
- Đọc http://nginx.org/en/docs/beginners_guide.html


Đó không phải là cách để giúp bạn config nginx thành 1 reverse-proxy nhanh nhất, hay cấu hình để nginx chạy website PHP của bạn ngay lập tức. Nhưng là một tài liệu phải đọc nếu bạn dùng NGINX.

Có gì hay?
- Một ít kiến thức về SIGNAL
- Syntax config của NGINX
- Biết cách dùng các directive để config NGINX

Trích vài đoạn hay ho:

nginx consists of modules which are controlled by directives specified in the configuration file. Directives are divided into simple directives and block directives. A simple directive consists of the name and parameters separated by spaces and ends with a semicolon (;). A block directive has the same structure as a simple directive, but instead of the semicolon it ends with a set of additional instructions surrounded by braces ({ and }). If a block directive can have other directives inside braces, it is called a context (examples: events, http, server, and location).
Directives placed in the configuration file outside of any contexts are considered to be in the main context. The events and http directives reside in the main context, server in http, and location in server.
The rest of a line after the # sign is considered a comment. 

location / {
    root /data/www;
}
This location block specifies the “/” prefix compared with the URI from the request. For matching requests, the URI will be added to the path specified in the root directive, that is, to /data/www, to form the path to the requested file on the local file system. If there are several matching location blocks nginx selects the one with the longest prefix. The location block above provides the shortest prefix, of length one, and so only if all other location blocks fail to provide a match, this block will be used. 

A regular expression should be preceded with ~.  

đã đọc đến đây?

Hello world, bạn đã trở thành NGINX beginner

Bài tiếp theo:
http://www.familug.org/2014/08/nginx-luat-matching-khi-chon-location-e.html

No comments:

Post a Comment