Nginx 프로필 - 3

4129 단어 Nginx프로필
흑백 명단 설정:
  :
allow
deny

    :
http, server, location, limit_except

    :
server {
    server_name www.a.com;
    listen 80;
    root /web/a.com;
    index index.html;
    server_tokens off;

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

    location /test1 {
        alias /mydata/html;
    }

}

    :
[root@www21:17:48~]#curl http://www.a.com/test/ 

test location page for nginx

: allow 172.20.23.33; ---> deny : [root@www21:21:16~]#curl http://www.a.com/test/ 403 Forbidden

사용자 기반 인증:
    :
auth_basic "    "
    :
Syntax: auth_basic string | off;
Default:    
auth_basic off;
Context:http, server, location, limit_except

auth_basic_user_file
    :
Syntax: auth_basic_user_file file;
Default:    —
Context:http, server, location, limit_except

    :
server {
        location /test1 {
        alias /mydata/html;
        auth_basic "test nginx";
        auth_basic_user_file /etc/nginx/conf.d/.npasswd;
    }
}

      :
[root@www21:28:47conf.d]#htpasswd -c -m /etc/nginx/conf.d/.npasswd tom
New password: 
Re-type new password: 
Adding password for user tom

  :
[root@www21:32:56~]#curl -u tom:123456 http://www.a.com/test1/

test alias for nginx


상태 정보 보기:
stub_status  on|off

    :
server {
    location /status {
        stub_status on;
        allow 172.20.23.33;
        deny all;
     }

}

      :
Active connections:    ,         
accepts:    ,              
handled:    ,                
requests:    ,            
Reading:    ,                     
Writing:    ,                    
Waiting:    ,                 

접근 로그 형식 설정:
    :
log_format [log_name] '$1 $2 $3';
   http  
      :
access_log path [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]];

    :
       :
log_format test '$remote_addr:$remote_port $request_method $remote_user $status $http_user_agent $bytes_sent $gzip_ratio';  
       :
server {
    server {
    server_name www.a.com;
    listen 80;
    root /web/a.com;
    index index.html;
    server_tokens off;
    access_log /web/a.com/a.com.log test;
}

http         :
 $uri:     uri,    
 $host:http     host  ,       host  ,             
    !
 $request_uri:   uri,     
 $hostname:nginx            
 $remote_addr:   ip
 $remote_port:     
 $remote_user:                  
 $request_filename:      RUI    root alias              
 $request_method:    
 $server_addr:     
 $server_name:     
 $server_port:     
 $server_protocol:                 http/1.1
 $scheme:       scheme, https http,    
 $http_HEADER:          HEADER  $http_host        host  
 $sent_http_HEADER:          HEADER---   
    :$http_content_type        content-type  
 $document_root:        root   
      : 
 $status:       
 $bytes_sent:      
 $http_referer:          
 $http_user_agent:      
 $gzip_ratio:    ,      

로그 캐 시 설정:
open_log_file_cache max=N [inactive=time] [min_uses=N] [valid=time];  

open_log_file_cache off;  
                  
max:              
min_uses: inactive                        
inactive:       
valid:                     

압축 기능:
    :
gzip on|off
    :
Syntax: gzip on | off;
Default:    
gzip off;
Context:http, server, location, if in location
     :
gzip_buffers [n]:       
gzip_comp_level[0--9]:    
gzip_distable [      ,     ]msie6
gzip_min_length [ ]:           
gzip_http_version:         ,       1.0/1.1
gzip_types:                   text/html
gzip_buffers number size;                          
  :32 4k   16 8k
gzip_vary on | off;      ,           “Vary: Accept-Encoding

    :
server {
        location /test3/ {
        gzip on;
        gzip_comp_level 6;
        gzip_min_length 100;
        gzip_types text/xml text/css text/plain application/javascript;
    }
}

  :
172.20.23.33:44018 GET - 200 curl/7.29.0  200 436946 "-" -->   
172.20.23.33:44020 GET - 200 curl/7.29.0  200 3252 "134.86"-->   

좋은 웹페이지 즐겨찾기