2025-03-19 15:04:57 +08:00

47 lines
1.9 KiB
Nginx Configuration File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}