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

31 lines
1.5 KiB
Plaintext
Raw Permalink 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.

server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html/localhost;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html/localhost;
}
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压缩
}