Nginx 的 HTTP 配备

Nginx 的 HTTP 配置

HTTP module 包含 3 个 logical blocks:

http, server, location.

server 包含在 http block 中, location 包含在 server block 或者其他的 location block 中。结构如图:

 

Nginx 的 HTTP 配备

 

引用自 <Nginx HTTP server>

 

全局 directive 和局部 directive 类似普通编程语言:

 

 

http {
    # Enable gzip compression at the http block level
    gzip on;
    server {
          server_name localhost;
          listen 80;
          # At this stage, gzip still set to on
          location /downloads/ {
                gzip off;
                # This directive only applies to documents found
                # in /downloads/
           }
     }
}