Nginx 프로필 매개 변수

구체 적 인 설정 항목 소개:
      :
Main               
         
         
              
         

    :
1 user [username groupname]:          
2 pid /path/to/pidfile_name:  nginx pid  
  :
1     pid      
2                
3 include file | mask  
               
4 load_module file:    
        :/usr/share/nginx/modules/*.conf  
            : /usr/lib64/nginx/modules

성능 최적화 관련 설정:
1 worker_processes [n]:work      
  :       
      cpu       1[   ]
auto --      cpu    
    :
[root@www19:15:31nginx]#ps aux | grep nginx
root       1328  0.0  0.4 120796  2236 ?        Ss   19:15   0:00 nginx: master process /usr/sbin/nginx
nginx      1329  0.0  0.6 121180  3120 ?        S    19:15   0:00 nginx: worker process
nginx      1330  0.0  0.6 121180  3120 ?        S    19:15   0:00 nginx: worker process
nginx      1331  0.0  0.6 121180  3120 ?        S    19:15   0:00 nginx: worker process

2 worker_cpu_affinity [cpumask]:        cpu
 0000:     
 0001: 0 cpu
 0010:   cpu
 0100:   cpu
 1000:   cpu
 0011:   0     cpu
    :       
worker_cpu_affinity 0001 0010 0100 1000;
              cpu   ,     
cpu         

ps axo psr,pid,cmd --  cpu    
    :
worker_cpu_affinity 0001 0010 0100;
  :
[root@www19:18:22~]#ps axo pid,cmd,psr | grep nginx
  1328 nginx: master process /usr/   2
  1374 nginx: worker process         0
  1375 nginx: worker process         1
  1376 nginx: worker process         2

3 worker_priority [nice ]:nice        
 -20---19    
  worker   nice ,       !
  nice   0:
[root@www19:19:42~]#ps axo pid,cmd,psr,ni | grep nginx
  1328 nginx: master process /usr/   2   0
  1374 nginx: worker process         0   0
  1375 nginx: worker process         1   0
  1376 nginx: worker process         2   0
  nice :
worker_priority 10;
  :
[root@www19:24:21~]#ps axo pid,cmd,psr,ni | grep nginx
  1328 nginx: master process /usr/   3   0
  1420 nginx: worker process         0  10
  1421 nginx: worker process         1  10
  1422 nginx: worker process         2  10

4 worker_rlimit_nofile [n]:
    worker             
       
         ,         socket  
    :
worker_rlimit_nofile 10240;
  :
ab -c 1025 -n 4000 http://172.20.23.48/
           !
             ,            :
ulimit -a   :open files (-n) 1024
      :/etc/security/limits.conf
            
Apache          hard     nofile   3000
nginx           hard     nofile   4000

  ulimit -n [n]:n=         

5 ssl_engine device:
   ssl          ,
      ssl      

6 timer_resolution [n]: 
          -        ,       gettimeofday()    
         ,   nginx    !
  x86_64   ,gettimeofday       ,       

이벤트 구동 관련 설정:
1 use [epoll|rtsig|select|poll];
         ,   nginx     ,linux    epoll

2 worker_connections [n];
  worker            
   web   :       worker_rlimit_nofile [n]
        ,worker_rlimit_nofile [n]        2 
 ulimit -a          !

3 accept_mutex [on|off]:
    nginx      ,       worker  
   ,            TCP  ,      worker
           7/8 ,maseter            worker
on--      
off--       ,           ,  "    "    

4 multi_accept {on|off};
                ,   off

5 accept_mutex_delay [n]  ;
accept    ,  worker     accept  
    ,[   worker                n        ]
   500  

디버그 | 테스트 관련 설정:
1 daemon [on|off];
   nginx        on,        off,           
   !       !  docker   ,     off

2 master_process[on|off];
     master           ,   on
      ,    off,     worker  

3 error_log /path/to/error_log level[  ];
          ,       debug  ,       --with-debug  
debug  !
   error  
       --with-debug   debug  

  :file /path/logfile;  
stderr:         
syslog:server-address[,parameter=values]:   
syslog memory:size     
  :
level:debug|info|notice|warn|error|crit|alter|emerg

네트워크 관련 설정:
1 keepalive_timeout [time];
            
      75 
   0    
   http|server|location
  telnet  :
[root@www19:47:59nginx]#telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
GET / HTTP/1.1                          
HOST: 172.20.23.48
HTTP/1.1 200 OK

2 keepalive_requests n;                 ;
    :
keepalive_timeout   75;
keepalive_requests  2; 

3 keepalive_disables [msie6|safari|none]
              

4 tcp_nodelay on|off:
        ,   on, 

5 client_header_timeout time[ ]
      http         

6 client_body_timeout time;
      http          ,  60 

7 send_timeout time;
             

8 client_body_buffer_size size;  
                  body        ;
       16k;                   client_body_temp_path        

9 client_body_temp_path path [level1 [level2 [level3]]];        
                body                    
        16     client_body_temp_path  /var/tmp/client_body  1 2 2  
    1 1    1 16  , 2^4=16    0-f  
    2 2    2 16  , 2^8=256    00-ff  
    2 3    2 16  , 2^8=256    00-ff 

클 라 이언 트 요청 의 제한:
1 limit_except   :               [    location]
   :
    limit_except GET {
            allow 172.16.0.0/16;              
            deny all;
            }
  GET        172.16.0.0/16        !
        :
GET -        
HEAD- GET  ,                    
POST -    ,  HTML    
PUT -        
DELETE -    URL     
OPTIONS -                  
    :
server {
    server_name www.a.com;
    listen 80;
    root /web/a.com;
    index index.html;
    server_tokens off;

    location /test {
        root /www/html;
            limit_except PUT {
                    deny 172.20.23.33;
                    deny 172.20.23.23;
                    allow all;
            }
    }

    location /test1 {
        alias /mydata/html;
    }

}
         PUT      172.20.23.33 
     
  :
[root@www21:16:01~]#curl -XGET http://www.a.com/test/ 

403 Forbidden

2 client_max_body_size size;
  http        ;            
         Content-Length   ,        

3 limit_rate      bytes/second;
                 
      0      ; 
   http|server|location

4 limit_rate_after time;
  nginx          ,              ,            
          !

파일 작업 최적화 관련:
1 sendfile on|off
    sendfile  ,        

sendfile:    on             。
sendfile   Nginx            tcp socket      。
         ,       (Nginx    )    buffer,
 read          cache,  cache        buffer,
  write           buffer      buffer,
   tcp socket。                  buffer。

2 aio on|off
    aio,     !      

3 open_file_cache max=N [inactive=time] on|off
max=N:        
inactive=time:     ,                  ,     
  60 
          ,        LRU      
       :
      ,    ,      
         
              

4 open_file_cache_errors on|off
                      
       -   off

5 open_file_cache_valid time;
                           60 

6 open_file_cache_min_use n;
 inactive                   ,     

7 directio size | off;  
            ,  directio 4m,  (  )   ,     

클 라 이언 트 요청 에 대한 특수 처리:
 1 ignore_invalid_headers on|off
           http  ,    on,off                 
       

 2 log_not_found on|off
                        !

 3 resolver address;
         nginx   dns     

 4 resolver_timeout time;
         DNS      ,  30s

 5 server_tokens [on|off];
              nginx    ;  off

좋은 웹페이지 즐겨찾기