This commit is contained in:
Evan
2026-09-07 09:55:36 +08:00
parent 9b6892f2ed
commit badbc11154
9098 changed files with 985321 additions and 0 deletions

106
nginx.conf Normal file
View File

@@ -0,0 +1,106 @@
server {
listen 80;
server_name localhost;
index index.html index.htm default.htm default.html;
root /usr/share/nginx/html;
# 1. 添加 resolver 指令
# 127.0.0.11 是 Docker 内置的 DNS 服务器地址 并且将缓存设置为10s
# resolver 127.0.0.11 valid=10s;
# gzip 配置
gzip on;
gzip_static on;
gzip_min_length 1k;
gzip_comp_level 6;
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
# 重定向规则
location = /c/scssn2025 {
return 301 /competition.html?competition_id=13;
}
# Unity 预压缩文件:禁止再次 gzip避免 Content-Length 与实际内容不一致
location ~* \.wasm\.br$ {
gzip off;
gzip_static off;
default_type application/wasm;
add_header Content-Encoding br;
add_header Content-Type application/wasm always;
add_header Vary Accept-Encoding;
add_header Accept-Ranges bytes;
expires 1h;
}
location ~* \.js\.br$ {
gzip off;
gzip_static off;
default_type application/javascript;
add_header Content-Encoding br;
add_header Content-Type application/javascript always;
add_header Vary Accept-Encoding;
add_header Accept-Ranges bytes;
expires 1h;
}
location ~* \.data\.br$ {
gzip off;
gzip_static off;
default_type application/octet-stream;
add_header Content-Encoding br;
add_header Vary Accept-Encoding;
add_header Accept-Ranges bytes;
expires 1h;
}
# 通用 Brotli 文件处理
location ~* \.br$ {
gzip off;
gzip_static off;
add_header Content-Encoding br;
add_header Vary Accept-Encoding;
add_header Accept-Ranges bytes;
expires 1h;
}
# 静态资源缓存配置
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
error_log off;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 12h;
error_log off;
access_log off;
}
# 路径需与 unityCdnRemote 保持一致,更新 OSS 目录时同步修改
# location /cdn-unity/ {
# # 2. 将域名赋值给一个变量
# set $oss_backend "https://oss.eanic.cn";
# # 3. proxy_pass 使用变量,这样 Nginx 就会在运行时解析域名
# proxy_pass $oss_backend/001_code_cocos_res_20260616/;
# proxy_ssl_server_name on;
# proxy_set_header Host oss.eanic.cn;
# proxy_hide_header Access-Control-Allow-Origin;
# expires 7d;
# }
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache, no-store";
}
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md) {
return 404;
}
# 错误日志和访问日志配置
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}