Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-middle-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
xingmin
yd-middle-front
Commits
1666420d
Commit
1666420d
authored
Sep 05, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
配置 test
parent
ee37e1ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
12 deletions
+38
-12
nginx.conf
+38
-12
No files found.
nginx.conf
View file @
1666420d
...
...
@@ -2,31 +2,57 @@ server {
listen
6666
;
server_name
localhost
;
# 处理前端静态资源(Vue应用)
location
/
{
root
/usr/share/nginx/html
;
index
index.html
;
try_files
$uri
$uri
/
/index.html
;
# 处理Vue路由history模式
if
(
$request_method
=
OPTIONS)
{
index
index.html
index.htm
;
try_files
$uri
$uri
/
/index.html
;
# 处理OPTIONS预检请求
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,
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-Type'
'text/plain
;
charset=utf
-8'
;
add_header
'Content-Length'
0
;
return
204
;
}
# 限制允许的HTTP方法
limit_except
GET
POST
PUT
DELETE
OPTIONS
{
deny
all
;
}
}
location
^~/
{
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/
;
}
# 代理后端API请求 - 使用更具体的路径
location
/api/
{
proxy_pass
http://139.224.145.34:9002/
;
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_buffer_size
1024k
;
proxy_buffers
16
1024k
;
proxy_busy_buffers_size
2048k
;
proxy_temp_file_write_size
2048k
;
# 处理OPTIONS预检请求(确保后端API也支持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,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
;
return
204
;
}
}
# 可能需要代理其他后端服务
# 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