49 lines
1.6 KiB
Plaintext
49 lines
1.6 KiB
Plaintext
|
|
# 开启gzip
|
|||
|
|
gzip on;
|
|||
|
|
# 启用gzip压缩的最小文件,小于设置值的文件将不会压缩
|
|||
|
|
gzip_min_length 1k;
|
|||
|
|
# gzip 压缩级别,1-9,数字越大压缩的越好,也越占用CPU时间,后面会有详细说明
|
|||
|
|
gzip_comp_level 6;
|
|||
|
|
# 进行压缩的文件类型。javascript有多种形式。其中的值可以在 mime.types 文件中找到。
|
|||
|
|
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/vnd.ms-fontobject font/ttf font/opentype font/x-woff image/svg+xml;
|
|||
|
|
# 是否在http header中添加Vary: Accept-Encoding,建议开启
|
|||
|
|
gzip_vary on;
|
|||
|
|
# 禁用IE 6 gzip
|
|||
|
|
gzip_disable "MSIE [1-6]\.";
|
|||
|
|
# 设置压缩所需要的缓冲区大小
|
|||
|
|
gzip_buffers 32 4k;
|
|||
|
|
# 设置gzip压缩针对的HTTP协议版本
|
|||
|
|
gzip_http_version 1.0;
|
|||
|
|
|
|||
|
|
server {
|
|||
|
|
listen 80;
|
|||
|
|
server_name localhost;
|
|||
|
|
|
|||
|
|
location ~ ^/(admin|live)/ {
|
|||
|
|
proxy_pass http://api:8080;
|
|||
|
|
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_set_header X-Forwarded-Proto $scheme;
|
|||
|
|
|
|||
|
|
proxy_http_version 1.1;
|
|||
|
|
proxy_set_header Upgrade $http_upgrade;
|
|||
|
|
proxy_set_header Connection "upgrade";
|
|||
|
|
|
|||
|
|
proxy_read_timeout 300s;
|
|||
|
|
proxy_send_timeout 300s;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
location ~.*\.(js|css|png|jpg|jpeg|gif)$ {
|
|||
|
|
root /www;
|
|||
|
|
expires 30d;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
location / {
|
|||
|
|
root /www;
|
|||
|
|
try_files $uri /index.html;
|
|||
|
|
# 禁止缓存 HTML,以保证引用最新的 CSS 和 JS 资源
|
|||
|
|
expires -1;
|
|||
|
|
}
|
|||
|
|
}
|