前端项目结构

This commit is contained in:
2025-12-02 15:55:30 +08:00
parent 2a9e624ba9
commit 28787e5b29
18 changed files with 2545 additions and 2167 deletions

View File

@@ -0,0 +1,196 @@
# 开发环境统一入口配置
# 上游服务定义
upstream gateway {
server gateway:8080;
keepalive 32;
}
upstream portal {
server portal:3000;
keepalive 16;
}
upstream app-bidding {
server app-bidding:3001;
keepalive 16;
}
upstream app-customer-service {
server app-customer-service:3002;
keepalive 16;
}
upstream shared {
server shared:5000;
keepalive 16;
}
# WebSocket 升级配置
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# 主服务器配置
server {
listen 80;
server_name localhost;
# 安全头
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
# 开发环境允许所有跨域
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
add_header Access-Control-Allow-Headers "DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization" always;
# 健康检查
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
# ==================== 共享包服务ES Module + Module Federation ====================
location /shared/ {
proxy_pass http://shared:5000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $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;
# CORSES Module / Module Federation 必需)
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Methods "GET, OPTIONS" always;
add_header Access-Control-Allow-Headers "Content-Type" always;
# ES Module MIME 类型
if ($request_filename ~* \.(js|mjs)$) {
add_header Content-Type "application/javascript; charset=utf-8";
}
# 开发环境不缓存
add_header Cache-Control "no-cache, no-store, must-revalidate";
# HMR 支持
proxy_read_timeout 86400;
proxy_send_timeout 86400;
}
# ==================== API 网关代理 ====================
location /api/ {
proxy_pass http://gateway/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $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_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# WebSocket 代理
location /ws/ {
proxy_pass http://gateway/ws/;
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;
# WebSocket 超时设置
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
# ==================== 主应用Portal ====================
location / {
proxy_pass http://portal/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
# Vite HMR 支持
proxy_read_timeout 86400;
}
# ==================== 招投标应用 ====================
location /bidding {
rewrite ^/bidding/(.*)$ /$1 break;
proxy_pass http://app-bidding/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
# Vite HMR 支持
proxy_read_timeout 86400;
}
# 招投标应用静态资源
location /bidding/ {
proxy_pass http://app-bidding/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_read_timeout 86400;
}
# ==================== 智能客服应用 ====================
location /customer-service {
rewrite ^/customer-service/(.*)$ /$1 break;
proxy_pass http://app-customer-service/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_read_timeout 86400;
}
location /customer-service/ {
proxy_pass http://app-customer-service/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_read_timeout 86400;
}
# ==================== Nacos 管理界面(开发用) ====================
location /nacos/ {
proxy_pass http://nacos:8848/nacos/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
# 可选HTTPS 配置(开发环境使用自签名证书)
# server {
# listen 443 ssl http2;
# server_name localhost;
#
# ssl_certificate /etc/nginx/ssl/cert.pem;
# ssl_certificate_key /etc/nginx/ssl/key.pem;
# ssl_protocols TLSv1.2 TLSv1.3;
# ssl_ciphers HIGH:!aNULL:!MD5;
#
# # 其他配置同上...
# }

View File

@@ -0,0 +1,42 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# 日志格式
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
# 性能优化
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# Gzip 压缩
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml text/javascript
application/javascript application/json application/xml+rss;
# 上传大小限制
client_max_body_size 100M;
# 包含具体配置
include /etc/nginx/conf.d/*.conf;
}