From 7d0f738e75f5a2cb0e94557be0204378316e7b14 Mon Sep 17 00:00:00 2001 From: tiananlin Date: Wed, 27 Aug 2025 09:18:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Dockerfiles/=20Dockerfile-?= =?UTF-8?q?production/default.conf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ Dockerfile-production/default.conf | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Dockerfiles/ Dockerfile-production/default.conf diff --git a/Dockerfiles/ Dockerfile-production/default.conf b/Dockerfiles/ Dockerfile-production/default.conf new file mode 100644 index 0000000..3de8a37 --- /dev/null +++ b/Dockerfiles/ Dockerfile-production/default.conf @@ -0,0 +1,47 @@ +server { + listen 80; + server_name localhost; + + # 基础设置 + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + + client_max_body_size 100m; + + # 错误页面配置 + error_page 500 502 503 504 /50x.html; + location = /50x.html { + internal; # 仅用于内部错误请求 + } + + # Gzip 压缩设置 + gzip 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 ~* \.(jpg|jpeg|gif|ico|css|js)$ { + expires 7d; + add_header Cache-Control "public, no-transform"; + } + + # API 代理配置 + location /api/ { + proxy_pass http://learn-archives-api-svc:8080/api/; + 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_connect_timeout 30s; + proxy_send_timeout 60s; + proxy_read_timeout 60s; + proxy_buffering on; + } +} \ No newline at end of file