82 lines
2.4 KiB
YAML
82 lines
2.4 KiB
YAML
server:
|
|
port: 80
|
|
|
|
# Spring 配置
|
|
spring:
|
|
application:
|
|
name: microservice-gateway
|
|
cloud:
|
|
nacos:
|
|
discovery:
|
|
server-addr: 127.0.0.1:8848
|
|
namespace: public
|
|
gateway:
|
|
discovery:
|
|
locator:
|
|
enabled: true
|
|
lower-case-service-id: true
|
|
globalcors:
|
|
add-to-simple-url-handler-mapping: true # 解决 options 请求被拦截问题
|
|
corsConfigurations:
|
|
'[/**]':
|
|
# allowedOrigins: # 允许哪些网站的跨域请求 allowedOrigins: “*” 允许所有网站
|
|
# - "https://localhost:8001"
|
|
# - "https://localhost:8002"
|
|
# - "https://localhost:8003"
|
|
allowedOriginPatterns:
|
|
- "*"
|
|
allowedMethods: # 允许的跨域ajax的请求方式 “*” 允许所有
|
|
- "GET"
|
|
- "POST"
|
|
- "DELETE"
|
|
- "PUT"
|
|
- "OPTIONS"
|
|
allowedHeaders: "*" # 允许在请求中携带的头信息
|
|
allowCredentials: true # 是否允许携带cookie
|
|
maxAge: 360000 # 这次跨域检测的有效期
|
|
routes:
|
|
- id: user
|
|
uri: lb://microservice-provider-user
|
|
predicates:
|
|
- Path=/user/**
|
|
- Method=GET,POST
|
|
- id: access
|
|
uri: lb://microservice-provider-access
|
|
predicates:
|
|
- Path=/access/**
|
|
- Method=GET,POST
|
|
- id: access-websocket
|
|
uri: lb:ws://microservice-provider-access
|
|
predicates:
|
|
- Path=/access/websocket/**
|
|
- id: shop
|
|
uri: lb://microservice-provider-shop
|
|
predicates:
|
|
- Path=/shop/**
|
|
- Method=GET,POST
|
|
|
|
- id: test1
|
|
uri: lb://microservice-provider-test
|
|
predicates:
|
|
- Path=/test/**,/test1/**
|
|
- Method=GET,POST
|
|
filters:
|
|
- StripPrefix=1 # 跳过第一段 /test
|
|
|
|
- id: test2
|
|
uri: lb://microservice-provider-test
|
|
predicates:
|
|
- Path=/test2/{routes}
|
|
filters:
|
|
- SetPath=/hi/{routes}
|
|
|
|
- id: test3
|
|
uri: lb://microservice-provider-test
|
|
predicates:
|
|
- Path=/test3/**
|
|
filters:
|
|
- name: RedirectTo
|
|
args:
|
|
status: 302
|
|
url: https://www.baidu.com/?wd=
|