Nginx 프로필 nginx. conf 상세 설명

4661 단어
#  Nginx         
user www www;

#nginx   ,       CPU    。
worker_processes 8;

#          ,[ debug | info | notice | warn | error | crit ]
error_log logs/error.log info;

#    
pid logs/nginx.pid;

#  nginx              ,             (    ulimit -n) nginx     ,  nginx        ,     ulimit -n      。
worker_rlimit_nofile 65535;

#          
events
{
#      ,use [ kqueue | rtsig | epoll | /dev/poll | select | poll ]; epoll   Linux 2.6             I/O  ,    FreeBSD  ,  kqueue  。
use epoll;
#         (     =   *   )
worker_connections 65535;
}

#  http   
http
{
	include mime.types; #             
	default_type application/octet-stream; #      
	#charset utf-8; #    
	server_names_hash_bucket_size 128; #      hash   
	client_header_buffer_size 32k; #        
	large_client_header_buffers 4 64k; #     
	client_max_body_size 8m; #     
	sendfile on; #          ,sendfile    nginx    sendfile       ,         on,             IO     ,    off,        I/O    ,       。  :              off。
	autoindex on; #        ,       ,    。
	tcp_nopush on; #      
	tcp_nodelay on; #      
	keepalive_timeout 120; #       ,    

	#FastCGI              :      ,      。             。
	fastcgi_connect_timeout 300;
	fastcgi_send_timeout 300;
	fastcgi_read_timeout 300;
	fastcgi_buffer_size 64k;
	fastcgi_buffers 4 64k;
	fastcgi_busy_buffers_size 128k;
	fastcgi_temp_file_write_size 128k;

	#gzip    
	gzip on; #  gzip    
	gzip_min_length 1k; #        
	gzip_buffers 4 16k; #     
	gzip_http_version 1.0; #    (  1.1,     squid2.5   1.0)
	gzip_comp_level 2; #    
	gzip_types text/plain application/x-javascript text/css application/xml;
	#    ,       text/html,          ,         ,      warn。
	gzip_vary on;
	#limit_zone crawler $binary_remote_addr 10m; #    IP          

	upstream youtuyouliao {
	#upstream     ,weight   ,            。weigth      ,             。
	server 192.168.80.121:80 weight=3;
	server 192.168.80.122:80 weight=2;
	server 192.168.80.123:80 weight=3;
	}

	#       
	server
	{
		#    
		listen 80 default_server; 
		#       ,     
		server_name www.youtuyouliao.com youtuyouliao.com;
		index index.html index.htm;

		#      
		log_format access '$remote_addr - $remote_user [$time_local] "$request" '
		'$status $body_bytes_sent "$http_referer" '
		'"$http_user_agent" $http_x_forwarded_for';
		#            
		access_log logs/access.log access;

		#  "/"       
		location / {
			proxy_pass http://youtuyouliao;
			proxy_redirect off;
			proxy_set_header X-Real-IP $remote_addr;
			#   Web       X-Forwarded-For      IP
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			#            ,  。
			proxy_set_header Host $host;
			client_max_body_size 10m; #                
			client_body_buffer_size 128k; #                  ,
			proxy_connect_timeout 90; #nginx            (      )
			proxy_send_timeout 90; #           (      )
			proxy_read_timeout 90; #     ,         (      )
			proxy_buffer_size 4k; #       (nginx)             
			proxy_buffers 4 32k; #proxy_buffers   ,     32k     
			proxy_busy_buffers_size 64k; #        (proxy_buffers*2)
			proxy_temp_file_write_size 64k;
			#         ,     ,  upstream    
		}

		#    
		location ~ ^/(WEB-INF)/ {   
			    deny all;   
		}

		#    Nginx     
		location /NginxStatus {
			stub_status on;
			access_log on;
			auth_basic "NginxStatus";
			auth_basic_user_file conf/htpasswd;
			#htpasswd        apache   htpasswd     。
		}

		#            
		#  jsp      tomcat resin  
		location ~ .(jsp|jspx|do)?$ {
			proxy_pass http://youtuyouliao;
			proxy_set_header Host $host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		}
		#       nginx       tomcat resin
		location ~ .*.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$ { 
			expires 15d; 
		}

		#JS CSS      
		location ~ .*.(js|css)?$ { 
			expires 1h;
		}
	}
}

좋은 웹페이지 즐겨찾기