Gateway 网关配置实用技巧
一 路由与断言设计
二 过滤器与全局处理
三 性能与可靠性调优
四 安全与高可用
五 配置示例与落地清单
server:
port: 10086
spring:
application:
name: gateway
cloud:
nacos:
server-addr: localhost:8848
gateway:
globalcors:
cors-configurations:
'[/**]':
allowedOrigins: "https://your-frontend.example.com"
allowedMethods:
- GET
- POST
- PUT
- DELETE
allowedHeaders: "*"
routes:
- id: user-service
uri: lb://userservice
predicates:
- Path=/api/user/**
filters:
- StripPrefix=1
- AddRequestHeader=X-Gateway-From, Gateway
metadata:
response-timeout: 5000ms
httpclient:
connect-timeout: 2s
response-timeout: 5s
pool:
type: ELASTIC
max-connections: 1000
max-idle-time: 60000
acquire-timeout: 5000
compression:
enabled: true
mime-types: text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json
min-response-size: 1024
route-definition-locator:
cache:
enabled: true
initial-capacity: 1000
maximum-size: 10000
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。