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
99e7cc48
Commit
99e7cc48
authored
Mar 16, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
17c8cb1d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
41 deletions
+23
-41
nginx.conf
+23
-41
No files found.
nginx.conf
View file @
99e7cc48
# 定义网关服务的负载均衡组
upstream
gateway_load_balance
{
server
139.224.150.79
:
9010
;
# 管理节点服务器上的网关实例
server
139.224.149.150
:
9011
;
# 工作节点服务器上的网关实例
}
server
{
server
{
listen
2669
;
listen
6688
;
server_name
_
;
server_name
139
.224.145.34
;
# 处理前端静态资源(Vue应用)
location
/
{
root
/usr/share/nginx/html
;
root
/usr/share/nginx/html
;
index
index.html
;
index
index.html
;
try_files
$uri
$uri
/
/index.html
;
# 处理Vue路由history模式
# 静态资源处理 - 必须放在最前面
if
(
$request_method
=
OPTIONS)
{
location
~
*
\
.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|map)
$
{
# ✅ 关键:添加 try_files 指令
try_files
$uri
=
404
;
# 确保静态资源有正确的过期时间和缓存头
expires
1y
;
add_header
Cache-Control
"public,
immutable"
;
# 为静态资源添加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-Origin'
'*'
;
add_header
'Access-Control-Allow-Methods'
'GET,
POST,
PUT,
DELETE,
OPTIONS'
;
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-Allow-Headers'
'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'
;
add_header
'Access-Control-Max-Age'
1728000
;
add_header
'Access-Control-Max-Age'
1728000
;
add_header
'Content-Type'
'text/plain
charset=UTF-8'
;
add_header
'Content-Length'
0
;
add_header
'Content-Length'
0
;
add_header
'Content-Type'
'text/plain
;
charset=UTF-8'
;
return
204
;
return
204
;
}
}
}
# 健康检查接口
limit_except
GET
POST
PUT
DELETE
OPTIONS
{
location
/health
{
deny
all
;
access_log
off
;
}
return
200
"healthy
\
n"
;
add_header
Content-Type
text/plain
;
}
}
# 前端路由处理 - 放在最后,作为兜底规则
# 代理后端API请求 - 使用更具体的路径
location
/
{
location
/api/
{
try_files
$uri
$uri
/
/index.html
;
# 处理Vue路由history模式
proxy_buffer_size
1024k
;
#设置代理服务器(nginx)保存用户头信息的缓冲区大小
proxy_buffers
16
1024k
;
#proxy_buffers缓冲区,网页平均在32k以下的设置
# 为页面添加CORS头
proxy_busy_buffers_size
2048k
;
#高负荷下缓冲大小(proxy_buffers*2)
add_header
'Access-Control-Allow-Origin'
'*'
always
;
proxy_temp_file_write_size
2048k
;
#设定缓存文件夹大小,大于这个值,将从upstream服务器传
add_header
'Access-Control-Allow-Methods'
'GET,
POST,
PUT,
DELETE,
OPTIONS'
always
;
proxy_pass
http://139.224.145.34:9002/
;
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
;
}
}
# 可能需要代理其他后端服务
# location /other-service/ {
# proxy_pass http://other-service:port/;
# }
}
}
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