Files
aigc-frontend/nginx.conf

40 lines
1.2 KiB
Nginx Configuration File

server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# gzip 压缩
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_min_length 1024;
# 静态资源缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|otf)$ {
expires 30d;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# API 反向代理(动态配置,启动时由 entrypoint.sh 替换占位符)
# BEGIN_API_PROXY
location @@API_LOCATION@@ {
proxy_pass @@API_TARGET@@;
proxy_set_header Host $proxy_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;
}
# END_API_PROXY
# SPA 路由:所有请求回退到 index.html
location / {
try_files $uri $uri/ /index.html;
}
# 安全响应头
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
}