#user nobody; worker_processes 1; error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; pid logs/nginx.pid; events{ worker_connections 1024; } http{ #access_log logs/access.log main; access_log off; #设定mime类型,类型由mime.type文件定义 include mime.types; default_type application/octet-stream; sendfile on; server_names_hash_bucket_size 256; #连接超时时间 keepalive_timeout 10; tcp_nodelay on; #开启gzip压缩 gzip on; gzip_disable "MSIE [1-6].(?!.*SV1)"; #设定请求缓冲 client_header_buffer_size 32k; large_client_header_buffers 4 32k; #设定负载均衡的服务器列表 #后端的Web服务器可以通过X-Forwarded-For获取用户真实IP proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 100m; #允许客户端请求的最大单文件字节数 client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数, proxy_connect_timeout 900; #nginx跟后端服务器连接超时时间(代理连接超时) proxy_send_timeout 900; #后端服务器数据回传时间(代理发送超时) proxy_read_timeout 900; #连接成功后,后端服务器响应时间(代理接收超时) proxy_buffer_size 4k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小 proxy_buffers 4 256k; #proxy_buffers缓冲区,网页平均在32k以下的话,这样设置 proxy_busy_buffers_size 512k; #高负荷下缓冲大小(proxy_buffers*2) proxy_temp_file_write_size 512k; #设定缓存文件夹大小,大于这个值,将从upstream服务器传 proxy_redirect off; proxy_cache_valid 200 5m; proxy_cache_valid 301 1m; proxy_cache_valid any 1m; proxy_cache_key $uri$is_args$args; expires 5m; index index.html index.htm index.php; ##配置默认站点 server{ listen 0.0.0.0:80 default; index index.html index.htm; location / { root html; } location /status { stub_status on; auth_basic "NginxStatus"; } location ~ .php$ { include fastcgi_params; fastcgi_index index.php; fastcgi_pass unix:/tmp/php.socket; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } include vhost/*.conf; }