Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-csf-front
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yuzhenWang
yd-csf-front
Commits
c0595196
Commit
c0595196
authored
Nov 13, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
配置
parent
98c6fe67
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
29 deletions
+56
-29
.env.production
+1
-4
Dockerfile
+2
-2
nginx.conf
+52
-22
package.json
+1
-1
No files found.
.env.production
View file @
c0595196
...
...
@@ -5,7 +5,4 @@ VITE_APP_TITLE = CSF-CORE
VITE_APP_ENV = 'production'
# 若依管理系统/生产环境
VITE_APP_BASE_API = '/prod-api'
# 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS = gzip
VITE_APP_BASE_API = '/api'
Dockerfile
View file @
c0595196
...
...
@@ -45,7 +45,7 @@ RUN ls -la node_modules/esbuild/bin && \
# 复制源码并构建
COPY
. .
RUN
npm run build:
dev
RUN
npm run build:
prod
# 生产阶段
FROM
docker.m.daocloud.io/library/nginx:alpine
...
...
@@ -60,5 +60,5 @@ RUN echo "https://mirrors.aliyun.com/alpine/v3.22/main/" > /etc/apk/repositories
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
&&
\
echo
"Asia/Shanghai"
>
/etc/timezone
EXPOSE
6688
EXPOSE
8102
CMD
["nginx", "-g", "daemon off;"]
nginx.conf
View file @
c0595196
# 定义网关服务的负载均衡组
upstream
gateway_load_balance
{
server
192.168.7.4
:
9010
;
# 管理节点服务器上的网关实例
server
192.168.7.5
:
9011
;
# 工作节点服务器上的网关实例
}
server
{
listen
6688
;
server_name
139
.224.1
45.34
;
listen
8102
;
server_name
139
.224.1
21.29
;
# 处理前端静态资源(Vue应用)
location
/
{
root
/usr/share/nginx/html
;
index
index.html
;
try_files
$uri
$uri
/
/index.html
;
# 处理Vue路由history模式
if
(
$request_method
=
OPTIONS)
{
# 为静态资源添加CORS头(可选)
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-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'
always
;
}
# 代理API请求到网关服务
location
/api/
{
# 负载均衡到两个网关服务实例
proxy_pass
http://gateway_load_balance/
;
# 代理设置
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
30s
;
proxy_read_timeout
30s
;
proxy_send_timeout
30s
;
# 缓冲区设置
proxy_buffering
on
;
proxy_buffer_size
4k
;
proxy_buffers
8
4k
;
# CORS 头
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-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'
always
;
# 处理OPTIONS请求(CORS预检)
if
(
$request_method
=
'OPTIONS')
{
add_header
'Access-Control-Allow-Origin'
'*'
;
add_header
'Access-Control-Allow-Methods'
'GET,
POST,
PUT,
DELETE,
OPTIONS'
;
add_header
'Access-Control-Allow-Headers'
'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'
;
add_header
'Access-Control-Allow-Headers'
'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type
,Authorization
'
;
add_header
'Access-Control-Max-Age'
1728000
;
add_header
'Content-Type'
'text/plain
charset=UTF-8'
;
add_header
'Content-Length'
0
;
add_header
'Content-Type'
'text/plain
;
charset=UTF-8'
;
return
204
;
}
limit_except
GET
POST
PUT
DELETE
OPTIONS
{
deny
all
;
}
}
# 代理后端API请求 - 使用更具体的路径
location
/api/
{
proxy_buffer_size
1024k
;
#设置代理服务器(nginx)保存用户头信息的缓冲区大小
proxy_buffers
16
1024k
;
#proxy_buffers缓冲区,网页平均在32k以下的设置
proxy_busy_buffers_size
2048k
;
#高负荷下缓冲大小(proxy_buffers*2)
proxy_temp_file_write_size
2048k
;
#设定缓存文件夹大小,大于这个值,将从upstream服务器传
proxy_pass
http://139.224.145.34:9002/
;
# 健康检查接口
location
/health
{
access_log
off
;
return
200
"healthy
\
n"
;
add_header
Content-Type
text/plain
;
}
# 可能需要代理其他后端服务
# location /other-service/ {
# proxy_pass http://other-service:port/;
# }
}
}
\ No newline at end of file
package.json
View file @
c0595196
...
...
@@ -9,7 +9,7 @@
"dev"
:
"vite"
,
"build"
:
"vite build"
,
"build:dev"
:
"vite build --mode=development"
,
"build:prod"
:
"vite build"
,
"build:prod"
:
"vite build
--mode=production
"
,
"build:stage"
:
"vite build --mode staging"
,
"preview"
:
"vite preview"
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment