From 2e7e90f411912afe7580c075a02a45dd6c92a528 Mon Sep 17 00:00:00 2001 From: zg Date: Thu, 16 Jul 2026 08:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mokee-gateway-web/Dockerfile | 1 + mokee-gateway-web/nginx/nginx.conf | 52 ++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 mokee-gateway-web/nginx/nginx.conf diff --git a/mokee-gateway-web/Dockerfile b/mokee-gateway-web/Dockerfile index fa527d6..3678599 100644 --- a/mokee-gateway-web/Dockerfile +++ b/mokee-gateway-web/Dockerfile @@ -1,3 +1,4 @@ FROM harbor.zgitm.com/library/nginx:alpine COPY dist/ /usr/share/nginx/html/ +COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 \ No newline at end of file diff --git a/mokee-gateway-web/nginx/nginx.conf b/mokee-gateway-web/nginx/nginx.conf new file mode 100644 index 0000000..97063c3 --- /dev/null +++ b/mokee-gateway-web/nginx/nginx.conf @@ -0,0 +1,52 @@ +# ========================================== +# Vue 项目 Nginx 配置模板 +# 配合 Dockerfile.vue 使用 +# ========================================== + +server { + listen 80; + server_name localhost; + + # 日志格式 + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + # 站点根目录 + root /usr/share/nginx/html; + index index.html; + + # 静态资源长期缓存 + location /assets/ { + expires 30d; + add_header Cache-Control "public, immutable"; + } + + # Vue Router history 模式支持 + location / { + try_files $uri $uri/ /index.html; + } + + # API 代理(如果有后端代理需求,可在此配置) + # location /api/ { + # proxy_pass http://backend-server:8080/; + # proxy_set_header Host $host; + # proxy_set_header X-Real-IP $remote_addr; + # } + + # Gzip 压缩 + gzip on; + gzip_vary on; + gzip_comp_level 6; + gzip_types + text/plain + text/css + text/xml + text/javascript + application/json + application/javascript + application/xml+rss + application/x-javascript + image/svg+xml; + gzip_min_length 1024; + gzip_proxied any; +}