Files
001code-html--cocos/nginx.conf
2026-06-16 16:27:02 +08:00

81 lines
2.2 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.
server {
listen 80;
server_name localhost;
index index.html index.htm default.htm default.html;
root /usr/share/nginx/html;
# 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;
}
# Brotli 压缩 WebAssembly 文件处理
location ~* \.wasm\.br$ {
default_type "";
add_header Content-Encoding br;
add_header Content-Type application/wasm always;
add_header Vary Accept-Encoding;
expires 30d;
}
location ~* \.asm\.js\.br$ {
default_type "";
add_header Content-Encoding br;
add_header Content-Type application/javascript always;
add_header Vary Accept-Encoding;
expires 30d;
}
# 通用 Brotli 文件处理
location ~* \.br$ {
add_header Content-Encoding br;
add_header Vary Accept-Encoding;
expires 30d;
}
# 静态资源缓存配置
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;
}
# 纯 CDN/cdn-unity/ → OSS 游戏包config.js unityCdnUseSiteProxy: true
# 路径需与 unityCdnRemote 保持一致,更新 OSS 目录时同步修改
location /cdn-unity/ {
proxy_pass https://oss.eanic.cn/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;
}