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
4186d02b
Commit
4186d02b
authored
Nov 14, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
配置
parent
50abfb09
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
91 deletions
+54
-91
Dockerfile
+0
-1
csf.conf
+0
-68
nginx.conf
+54
-22
No files found.
Dockerfile
View file @
4186d02b
...
...
@@ -51,7 +51,6 @@ RUN npm run build:prod
FROM
docker.m.daocloud.io/library/nginx:alpine
COPY
--from=build /app/dist /usr/share/nginx/html
COPY
nginx.conf /etc/nginx/conf.d/default.conf
COPY
csf.conf /etc/nginx/conf.d/csf.conf
# 设置时区
RUN
echo
"https://mirrors.aliyun.com/alpine/v3.22/main/"
>
/etc/apk/repositories
&&
\
...
...
csf.conf
deleted
100644 → 0
View file @
50abfb09
# 定义网关服务的负载均衡组
upstream
gateway_load_balance
{
server
192
.
168
.
7
.
4
:
9010
;
# 管理节点服务器上的网关实例
server
192
.
168
.
7
.
5
:
9011
;
# 工作节点服务器上的网关实例
}
server
{
listen
2669
;
server_name
localhost
;
# 处理前端静态资源(Vue应用)
location
/ {
root
/
usr
/
share
/
nginx
/
html
;
index
index
.
html
;
try_files
$
uri
$
uri
/ /
index
.
html
;
# 处理Vue路由history模式
# 为静态资源添加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
30
s
;
proxy_read_timeout
30
s
;
proxy_send_timeout
30
s
;
# 缓冲区设置
proxy_buffering
on
;
proxy_buffer_size
4
k
;
proxy_buffers
8
4
k
;
# 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,Authorization'
;
add_header
'Access-Control-Max-Age'
1728000
;
add_header
'Content-Length'
0
;
add_header
'Content-Type'
'text/plain; charset=UTF-8'
;
return
204
;
}
}
# 健康检查接口
location
/
health
{
access_log
off
;
return
200
"healthy\n"
;
add_header
Content
-
Type
text
/
plain
;
}
}
\ No newline at end of file
nginx.conf
View file @
4186d02b
# 统一入口Nginx配置
upstream
middle_front
{
server
192.168.7.4
:
2100
;
server
192.168.7.5
:
2101
;
}
upstream
csf_front
{
server
192.168.7.4
:
2102
;
server
192.168.7.5
:
2103
;
# 定义网关服务的负载均衡组
upstream
gateway_load_balance
{
server
192.168.7.4
:
9010
;
# 管理节点服务器上的网关实例
server
192.168.7.5
:
9011
;
# 工作节点服务器上的网关实例
}
server
{
listen
80
;
server_name
center.supguard.cn
;
listen
2669
;
server_name
localhost
;
# 处理前端静态资源(Vue应用)
location
/
{
proxy_pass
http://middle_front
;
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
;
root
/usr/share/nginx/html
;
index
index.html
;
try_files
$uri
$uri
/
/index.html
;
# 处理Vue路由history模式
# 为静态资源添加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
;
}
}
server
{
listen
80
;
server_name
web.csf.supguard.cn
;
# 代理API请求到网关服务
location
/api/
{
# 负载均衡到两个网关服务实例
proxy_pass
http://gateway_load_balance/
;
location
/
{
proxy_pass
http://csf_front
;
# 代理设置
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,Authorization'
;
add_header
'Access-Control-Max-Age'
1728000
;
add_header
'Content-Length'
0
;
add_header
'Content-Type'
'text/plain
;
charset=UTF-8'
;
return
204
;
}
}
# 健康检查接口
location
/health
{
access_log
off
;
return
200
"healthy
\
n"
;
add_header
Content-Type
text/plain
;
}
}
\ No newline at end of file
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