refactor(project): Reorganize frontend and backend directories

This commit is contained in:
2026-03-18 10:45:15 +08:00
parent cc9eaf4cdf
commit 92a139e470
513 changed files with 28251 additions and 287 deletions
+207
View File
@@ -0,0 +1,207 @@
# Nginx 主配置文件
# 高可用负载均衡
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 10240;
use epoll;
multi_accept on;
}
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" '
'upstream: $upstream_addr '
'response_time: $upstream_response_time';
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_proxied any;
gzip_comp_level 6;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml application/json application/javascript application/xml;
# 请求体大小限制 (用于视频上传)
client_max_body_size 1024M;
client_body_buffer_size 128k;
# 代理超时配置
proxy_connect_timeout 60s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
# 代理头配置
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;
# 加载upstream配置
include /etc/nginx/conf.d/upstream.conf;
# 主服务配置
server {
listen 80;
listen [::]:80;
server_name _;
# 首页
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
# API网关路由
location /auth/ {
proxy_pass http://gateway_cluster/auth/;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
location /user/ {
proxy_pass http://gateway_cluster/user/;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
location /content/ {
proxy_pass http://gateway_cluster/content/;
proxy_http_version 1.1;
proxy_set_header Connection "";
# 视频流优化
proxy_buffering off;
proxy_request_buffering off;
}
location /comment/ {
proxy_pass http://gateway_cluster/comment/;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
location /recommend/ {
proxy_pass http://gateway_cluster/recommend/;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
location /admin/ {
proxy_pass http://gateway_cluster/admin/;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
# Nacos控制台
location /nacos/ {
proxy_pass http://nacos_cluster/nacos/;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
# Sentinel控制台
location /sentinel/ {
proxy_pass http://sentinel_cluster/;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
# MinIO API
location /minio/ {
proxy_pass http://minio_cluster/;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
}
# MinIO控制台
location /minio-console/ {
proxy_pass http://minio_console_cluster/;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# 健康检查端点
location /health {
access_log off;
return 200 'OK';
add_header Content-Type text/plain;
}
# 状态监控页面
location /nginx_status {
stub_status on;
access_log off;
allow 192.168.1.0/24;
deny all;
}
# 错误页面
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
# TCP/UDP 流代理 (用于Redis, MySQL等)
stream {
# MySQL负载均衡
upstream mysql_cluster {
server 192.168.1.101:3306 weight=1;
server 192.168.1.102:3306 weight=1 backup;
server 192.168.1.103:3306 weight=1 backup;
}
server {
listen 13306;
proxy_pass mysql_cluster;
proxy_connect_timeout 10s;
}
# Redis负载均衡 (读写分离)
upstream redis_master {
server 192.168.1.101:6379;
}
server {
listen 16379;
proxy_pass redis_master;
proxy_connect_timeout 5s;
}
# Redis Sentinel
upstream redis_sentinel {
server 192.168.1.101:26379;
server 192.168.1.102:26379;
server 192.168.1.103:26379;
}
server {
listen 26379;
proxy_pass redis_sentinel;
}
}