user nginx;
worker_processes 4; #nginx进程,一般设置为和cpu核数一样
error_log /data/logs/nginx/error.log warn; #错误日志存放目录
pid /var/run/nginx.pid; #进程pid存放位置
#工作模式及连接数上限
events {
worker_connections 1024; #连接数
}
http {
include /etc/nginx/mime.types; #文件扩展名与类型映射表
default_type application/octet-stream; #默认文件类型
charset utf-8;
server_names_hash_bucket_size 1280; #设定请求缓存
client_header_buffer_size 10240k;
large_client_header_buffers 16 5120k;
client_max_body_size 200m;
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 /var/log/nginx/access.log main;
access_log /data/logs/nginx/access.log main;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
#fastcgi_cache_path /usr/local/nginx/fastcgi_cache levels=1:2
# keys_zone=TEST:10m
# inactive=5m;
fastcgi_connect_timeout 3000s;
fastcgi_send_timeout 3000s;
fastcgi_read_timeout 3000s;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
proxy_redirect off;
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_ignore_client_abort on;
proxy_connect_timeout 6000;
proxy_send_timeout 6000;
proxy_read_timeout 6000;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
send_timeout 6000;
proxy_buffering off;
proxy_next_upstream error;
# fastcgi_cache_valid 200 302 1h;
# fastcgi_cache_valid 301 1d;
# fastcgi_cache_valid any 1m;
# fastcgi_cache_min_uses 1;
# fastcgi_cache_use_stale error timeout invalid_header http_500;
open_file_cache max=204800 inactive=20s;
open_file_cache_min_uses 1;
open_file_cache_valid 30s;
tcp_nodelay on;
gzip on;#开启gzip压缩功能
gzip_min_length 1k;
gzip_buffers 4 16k;#压缩缓冲区大小。表示申请4个单位为16K的内存作为压缩结果流缓存,默认值是申请与原始数据大小相同的内存空间来存储gzip压缩结果
gzip_http_version 1.0;#压缩版本(默认1.1,前端为squid2.5时使用1.0)用于设置识别HTTP协议版本,默认是1.1,目前大部分浏览器已经支持GZIP解压,使用默认即可。
gzip_comp_level 2;# 压缩比率。用来指定GZIP压缩比,1压缩比最小,处理速度最快;9压缩比最大,传输速度快,但处理最慢,也比较消耗cpu资源。
gzip_types text/plain application/x-javascript text/css application/xml; #用来指定压缩的类型,“text/html”类型总是会被压缩
gzip_vary on; #Squid缓存经过Nginx压缩的数据。
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
梳理:Nginx的配置文件详解
猜你喜欢
转载自blog.csdn.net/weixin_39076203/article/details/104029948
今日推荐
周排行