47 lines
1.9 KiB
Nginx Configuration File
47 lines
1.9 KiB
Nginx Configuration File
![]() |
|
|||
|
user root;
|
|||
|
worker_processes auto;
|
|||
|
|
|||
|
error_log /var/log/nginx/error.log warn;
|
|||
|
pid /var/run/nginx.pid;
|
|||
|
|
|||
|
|
|||
|
events {
|
|||
|
worker_connections 1024;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
http {
|
|||
|
include /etc/nginx/mime.types;
|
|||
|
default_type application/octet-stream;
|
|||
|
|
|||
|
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;
|
|||
|
|
|||
|
sendfile on;
|
|||
|
tcp_nopush on;
|
|||
|
tcp_nodelay on;
|
|||
|
keepalive_timeout 65;
|
|||
|
types_hash_max_size 2048;
|
|||
|
client_max_body_size 20m;
|
|||
|
client_body_buffer_size 20m;
|
|||
|
|
|||
|
#sendfile on;
|
|||
|
#tcp_nopush on;
|
|||
|
|
|||
|
#keepalive_timeout 65;
|
|||
|
|
|||
|
gzip on; #开启gzip压缩功能
|
|||
|
gzip_min_length 10k; #设置允许压缩的页面最小字节数; 这里表示如果文件小于10个字节,就不用压缩,因为没有意义,本来就很小.
|
|||
|
gzip_buffers 4 16k; #设置压缩缓冲区大小,此处设置为4个16K内存作为压缩结果流缓存
|
|||
|
gzip_http_version 1.1; #压缩版本
|
|||
|
gzip_comp_level 1; #设置压缩比率,最小为1,处理速度快,传输速度慢;9为最大压缩比,处理速度慢,传输速度快; 这里表示压缩级别,可以是0到9中的任一个,级别越高,压缩就越小,节省了带宽资源,但同时也消耗CPU资源,所以一般折中为6
|
|||
|
gzip_types text/plain text/css application/javascript text/javascript; #制定压缩的类型,线上配置时尽可能配置多的压缩类型!
|
|||
|
gzip_vary on; #选择支持vary header;改选项可以让前端的缓存服务器缓存经过gzip压缩的页面; 这个可以不写,表示在传送数据时,给客户端说明我使用了gzip压缩
|
|||
|
|
|||
|
include /etc/nginx/conf.d/*.conf;
|
|||
|
}
|