feat: 实现动态详情页面和性能优化
- 添加案例、新闻、产品详情页面的E2E测试 - 优化详情页面的客户端组件和页面逻辑 - 添加高性能Docker配置和Nginx配置 - 更新API服务和常量配置 - 添加性能优化文档和任务进度更新 - 修复ESLint错误和类型问题
This commit is contained in:
+111
@@ -0,0 +1,111 @@
|
||||
events {
|
||||
worker_connections 2048;
|
||||
use epoll;
|
||||
multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
upstream backend {
|
||||
least_conn;
|
||||
server app1:3001 max_fails=3 fail_timeout=30s;
|
||||
server app2:3002 max_fails=3 fail_timeout=30s;
|
||||
server app3:3003 max_fails=3 fail_timeout=30s;
|
||||
}
|
||||
|
||||
# 缓存配置
|
||||
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=app_cache:10m max_size=1g inactive=60m use_temp_path=off;
|
||||
|
||||
# 限流配置
|
||||
limit_req_zone $binary_remote_addr zone=general:10m rate=100r/s;
|
||||
limit_conn_zone $binary_remote_addr zone=addr:10m;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
# 健康检查端点
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
|
||||
# 静态资源缓存
|
||||
location /_next/static/ {
|
||||
proxy_pass http://backend;
|
||||
proxy_cache app_cache;
|
||||
proxy_cache_valid 200 365d;
|
||||
proxy_cache_use_stale error timeout updating;
|
||||
add_header X-Cache-Status $upstream_cache_status;
|
||||
expires 365d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# 图片资源缓存
|
||||
location ~* \.(jpg|jpeg|png|gif|webp|avif|svg|ico)$ {
|
||||
proxy_pass http://backend;
|
||||
proxy_cache app_cache;
|
||||
proxy_cache_valid 200 365d;
|
||||
proxy_cache_use_stale error timeout updating;
|
||||
add_header X-Cache-Status $upstream_cache_status;
|
||||
expires 365d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# API 路由
|
||||
location /api/ {
|
||||
proxy_pass http://backend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
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;
|
||||
|
||||
# API 缓存
|
||||
proxy_cache app_cache;
|
||||
proxy_cache_valid 200 5m;
|
||||
proxy_cache_methods GET HEAD;
|
||||
proxy_cache_bypass $http_pragma $http_authorization;
|
||||
|
||||
# 连接超时
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
# 主应用路由
|
||||
location / {
|
||||
limit_req zone=general burst=200 nodelay;
|
||||
limit_conn addr 10;
|
||||
|
||||
proxy_pass http://backend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
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_buffering on;
|
||||
proxy_buffer_size 4k;
|
||||
proxy_buffers 8 4k;
|
||||
proxy_busy_buffers_size 8k;
|
||||
|
||||
# 连接超时
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
# Gzip 压缩
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss application/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user