Commit 64b2ff61 by zhangxingmin

push

parent 30317d29
......@@ -2,10 +2,6 @@
upstream gateway_load_balance {
server 192.168.7.4:9010; # 管理节点服务器上的网关实例
server 192.168.7.5:9011; # 工作节点服务器上的网关实例
# 添加负载均衡策略
# least_conn; # 最少连接数
# ip_hash; # IP哈希(需要会话保持时)
}
server {
......@@ -17,7 +13,7 @@ server {
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;
......@@ -28,26 +24,23 @@ server {
location /api/ {
# 负载均衡到两个网关服务实例
proxy_pass http://gateway_load_balance;
# 注意:这里不要以斜杠结尾,保留原始路径 /api/xxx
# 如果网关需要去掉 /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;
......@@ -71,9 +64,4 @@ server {
return 200 "healthy\n";
add_header Content-Type text/plain;
}
# 全局方法限制(可选,也可以在每个location中单独设置)
limit_except GET POST PUT DELETE OPTIONS {
deny all;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment