- Dockerfile:多阶段构建,node:20-alpine 编译 Vue3, nginx:alpine 提供静态资源服务,使用国内 npm 镜像加速 - nginx.conf:配置 Vue Router history 模式(try_files), /api/ 和 /uploads/ 反向代理到后端容器 - .env.production:生产环境 API 地址(8.148.151.56:3001) - .gitignore:放开 .env.production 提交权限(无敏感信息)
22 lines
439 B
Nginx Configuration File
22 lines
439 B
Nginx Configuration File
server {
|
|
listen 80;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Vue Router history 模式支持
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# 反向代理后端 API
|
|
location /api/ {
|
|
proxy_pass http://backend:3001;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
}
|
|
|
|
location /uploads/ {
|
|
proxy_pass http://backend:3001;
|
|
}
|
|
}
|