Nginx配置优化实战

1、最顶层

worker_processes  4;
worker_cpu_affinity 0001 0010 0100 1000;
worker_rlimit_nofile 65535;

#worker_processes  4;Nginx运行工作进程数量
#worker_cpu_affinity 0001 0010 0100 1000;4核配置
#worker_rlimit_nofile 65535;Nginx最大打开文件数

 2、http

开启高效传输模式
sendfile        on;
tcp_nopush     on;
#设置允许发布内容为1024M
client_max_body_size 1024M;
client_body_buffer_size 256k;
underscores_in_headers on;
client_header_buffer_size 512k;
large_client_header_buffers 4 512k;
#keepalive_timeout  0;
keepalive_timeout  65;
#压缩配置
gzip  on;
gzip_min_length 2k;
gzip_buffers   4 32k;    
gzip_comp_level 4;

 3、server

缓存
	location ~* \.(js|css)$ {
	    expires 1d;
	    log_not_found off;
	    access_log off;
	}

        location /api {
            proxy_pass   http://competition;
	        proxy_set_header  Host $host;
            proxy_set_header   X-real-ip $remote_addr;
            proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
	        proxy_connect_timeout 900s;//504时间
    	    proxy_send_timeout 900s;//504时间
     	    proxy_read_timeout 900s;//504时间
        }

 

你可能感兴趣的:(nginx,nginx)