目录
一:nginx.conf相关设置
user www www;
worker_processes 4;
error_log /data/logs/nginx/error.log error;
pid logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll; 复用客户端线程的轮询方法
accept_mutex on;
worker_connections 65535;
multi_accept on;
}
连接数等:
http {
include mime.types;
default_type application/octet-stream;
charset utf-8;
server_names_hash_bucket_size 256;
client_header_buffer_size 128k;
large_client_header_buffers 16 128k;
client_max_body_size 256m;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log /data/logs/nginx/access.log main;
access_log off;
sendfile on; nginx在支持了sendfile系统调用后,避免了内核层与用户层的上线文切换(content swith)工作,大大减少了系统性能的开销
sendfile_max_chunk 0; 设置为512k
keepalive_timeout 65; 将keepalive_timeout时间调小会导致上传操作可能无法完成;调大点的话,许多无效的http连接占据着nginx的连接数
keepalive_requests 300; 长链接时间
send_timeout 60s;
autoindex off;
tcp_nopush on; 诉nginx在一个数据包里发送所有头文件,而不一个接一个的发送。
tcp_nodelay on; 告诉nginx不要缓存数据,而是一段一段的发送--当需要及时发送数据时
client_header_timeout 60; 设置请求头和请求体(各自)的超时时间。我们也可以把这个设置低些。
client_body_timeout 60;
reset_timedout_connection on; 告诉nginx关闭不响应的客户端连接
gzip on;
gzip_buffers 64 16k;
gzip_comp_level 5;
gzip_http_version 1.1;
gzip_min_length 1024;
gzip_proxied any;
gzip_vary on;
gzip_types text/javascript application/javascript application/x-javascript text/x-json application/json text/css text/plain image/jpeg image/gif image/jpg image/png; 设置压缩类型()
gzip_disable "MSIE [4-6]\.";
gzip_static on;
open_file_cache max=65535 inactive=20s; 缓存最大长度和缓存时间
open_file_cache_valid 30s; 缓存间隔时间
open_file_cache_min_uses 1;
open_file_cache_errors on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 256k;
fastcgi_buffers 16 64k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
proxy_connect_timeout 300s;
proxy_send_timeout 900;
proxy_read_timeout 900;
proxy_buffer_size 32k; 缓存后端数据大小
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_redirect off;
proxy_hide_header Vary;
proxy_set_header Accept-Encoding '';
proxy_set_header Host $host;
proxy_set_header Referer $http_referer;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
include vhost/*.conf; vhost里面是对应的域名配置文件
}