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; +}