当前位置: 首页 > news >正文

宁波网站制作价格厦门人才网招聘官网

宁波网站制作价格,厦门人才网招聘官网,生活服务平台,专题网站建设一、CORS 配置 你可以配置网关来控制全局或每个路由的 CORS 行为。两者都提供同样的可能性。 1. Global CORS 配置 “global” CORS配置是对 Spring Framework CorsConfiguration 的URL模式的映射。下面的例子配置了 CORS。 Example 77. application.yml spring:cloud:gat…

一、CORS 配置

你可以配置网关来控制全局或每个路由的 CORS 行为。两者都提供同样的可能性。

1. Global CORS 配置

“global” CORS配置是对 Spring Framework CorsConfiguration 的URL模式的映射。下面的例子配置了 CORS。

Example 77. application.yml

spring:cloud:gateway:globalcors:cors-configurations:'[/**]':allowedOrigins: "https://docs.spring.io"allowedMethods:- GET

在前面的例子中,对于所有GET请求的路径,允许来自 docs.spring.io 的请求的CORS请求。

要为未被某些网关路由谓词处理的请求提供相同的 CORS 配置,请将 spring.cloud.gateway.globalcors.add-to-simple-url-handler-mapping 属性设为 true。当你试图支持 CORS 预检请求,而你的路由谓词因为 HTTP 方法是 options 而不能评估为 true 时,这很有用。

2. 路由的 CORS 配置

“route” configuration 允许将CORS直接应用于带有key CORS 的路由作为元数据。像全局配置一样,这些属性属于 Spring Framework CorsConfiguration。

如果路由中没有 Path 谓词,则将应用 '/**'。

Example 78. application.yml

spring:cloud:gateway:routes:- id: cors_routeuri: https://example.orgpredicates:- Path=/service/**metadata:corsallowedOrigins: '*'allowedMethods:- GET- POSTallowedHeaders: '*'maxAge: 30

二、路由元数据配置

你可以通过使用元数据为每个路由配置额外的参数,如下所示。

Example 73. application.yml

spring:cloud:gateway:routes:- id: route_with_metadatauri: https://example.orgmetadata:optionName: "OptionValue"compositeObject:name: "value"iAmNumber: 1

你可以从一个 exchange 所获取所有的元数据属性,如下所示

Route route = exchange.getAttribute(GATEWAY_ROUTE_ATTR);
// get all metadata properties
route.getMetadata();
// get a single metadata property
route.getMetadata(someKey);

三、配置(Configuration)

Spring Cloud Gateway 的配置是由 RouteDefinitionLocator 实例的集合驱动的。下面的列表显示了 RouteDefinitionLocator 接口的定义。

Example 71. RouteDefinitionLocator.java

public interface RouteDefinitionLocator {Flux<RouteDefinition> getRouteDefinitions();
}

默认情况下,PropertiesRouteDefinitionLocator 通过使用Spring Boot的 @ConfigurationProperties 机制加载属性。

前面的配置例子都使用了一种快捷方式,即使用位置参数而不是命名参数。下面的两个例子是等价的。

Example 72. application.yml

spring:cloud:gateway:routes:- id: setstatus_routeuri: https://example.orgfilters:- name: SetStatusargs:status: 401- id: setstatusshortcut_routeuri: https://example.orgfilters:- SetStatus=401

对于网关的某些用途来说,属性已经足够了,但一些生产用例会从外部来源(如数据库)加载配置中受益。未来的里程碑版本将有基于 Spring Data Repository 的 RouteDefinitionLocator 实现,如 Redis、MongoDB和Cassandra。

四、TLS 和 SSL

网关可以通过遵循通常的 Spring server configuration 来监听 HTTPS 请求。下面的例子显示了如何做到这一点。

Example 67. application.yml

server:ssl:enabled: truekey-alias: scgkey-store-password: scg1234key-store: classpath:scg-keystore.p12key-store-type: PKCS12

你可以将网关路由到HTTP和HTTPS后端。如果你要路由到HTTPS后端,你可以通过以下配置将网关配置为信任所有下游的证书。

Example 68. application.yml

spring:cloud:gateway:httpclient:ssl:useInsecureTrustManager: true

使用不安全的 trust manager 不适合于生产。对于生产部署,你可以用一组已知的证书来配置网关,它可以通过以下配置来信任。

Example 69. application.yml

spring:cloud:gateway:httpclient:ssl:trustedX509Certificates:- cert1.pem- cert2.pem

如果 Spring Cloud Gateway 没有配置受信任的证书,就会使用默认的 trust store(你可以通过设置 javax.net.ssl.trustStore 系统属性来覆盖它)。

1. TLS 握手

网关维护着一个client pool,它用来路由到后端。当通过HTTPS进行通信时,客户端发起了一个TLS握手。一些 timeout 配置与这个握手相关。你可以对这些 timeouts 进行配置,如下(默认值)。

Example 70. application.yml

spring:cloud:gateway:httpclient:ssl:handshake-timeout-millis: 10000close-notify-flush-timeout-millis: 3000close-notify-read-timeout-millis: 0


文章转载自:
http://dinncozingiberaceous.tqpr.cn
http://dinncocairo.tqpr.cn
http://dinncobookworm.tqpr.cn
http://dinncoprivet.tqpr.cn
http://dinncoaluminize.tqpr.cn
http://dinncodrum.tqpr.cn
http://dinncolimnologist.tqpr.cn
http://dinncoecclesiolatry.tqpr.cn
http://dinncoframeable.tqpr.cn
http://dinncoflustration.tqpr.cn
http://dinncoparticiple.tqpr.cn
http://dinncoguessable.tqpr.cn
http://dinnconiedersachsen.tqpr.cn
http://dinncobeadsman.tqpr.cn
http://dinncobacchante.tqpr.cn
http://dinncoadobo.tqpr.cn
http://dinncosortilege.tqpr.cn
http://dinncolucre.tqpr.cn
http://dinncodotty.tqpr.cn
http://dinncoesthesis.tqpr.cn
http://dinncosporular.tqpr.cn
http://dinncoinformix.tqpr.cn
http://dinncoflour.tqpr.cn
http://dinncoimpotent.tqpr.cn
http://dinncothraldom.tqpr.cn
http://dinncooverfreight.tqpr.cn
http://dinncolothario.tqpr.cn
http://dinncoishikari.tqpr.cn
http://dinncoamphitheatric.tqpr.cn
http://dinncolucubrator.tqpr.cn
http://dinncograckle.tqpr.cn
http://dinncomusicianship.tqpr.cn
http://dinncoeducable.tqpr.cn
http://dinncofork.tqpr.cn
http://dinncomultinuclear.tqpr.cn
http://dinncocomprisal.tqpr.cn
http://dinncoextended.tqpr.cn
http://dinncoscarus.tqpr.cn
http://dinncowhipless.tqpr.cn
http://dinncoactual.tqpr.cn
http://dinncokamptulicon.tqpr.cn
http://dinncoencrypt.tqpr.cn
http://dinncoofm.tqpr.cn
http://dinncounquelled.tqpr.cn
http://dinncoquadragenarian.tqpr.cn
http://dinncocumquat.tqpr.cn
http://dinncocoo.tqpr.cn
http://dinncoinviolateness.tqpr.cn
http://dinncounary.tqpr.cn
http://dinncodiagrammatical.tqpr.cn
http://dinncoconvulsion.tqpr.cn
http://dinnconinefold.tqpr.cn
http://dinncoguesswork.tqpr.cn
http://dinncotooler.tqpr.cn
http://dinncogawkish.tqpr.cn
http://dinnconeighboring.tqpr.cn
http://dinncosafari.tqpr.cn
http://dinncopublishable.tqpr.cn
http://dinncodesiccated.tqpr.cn
http://dinncocoattail.tqpr.cn
http://dinncosunnism.tqpr.cn
http://dinncoonchocercosis.tqpr.cn
http://dinncosnappish.tqpr.cn
http://dinncoinburst.tqpr.cn
http://dinncoandrogynous.tqpr.cn
http://dinncocunning.tqpr.cn
http://dinncooutweep.tqpr.cn
http://dinncotamer.tqpr.cn
http://dinncoexpressions.tqpr.cn
http://dinncocanape.tqpr.cn
http://dinncotorii.tqpr.cn
http://dinncofinlandization.tqpr.cn
http://dinncogervais.tqpr.cn
http://dinncopyopericardium.tqpr.cn
http://dinncoherein.tqpr.cn
http://dinncobasketry.tqpr.cn
http://dinncolagomorphic.tqpr.cn
http://dinncopleopod.tqpr.cn
http://dinncokleptocracy.tqpr.cn
http://dinncoantifederal.tqpr.cn
http://dinncomilo.tqpr.cn
http://dinncoworthless.tqpr.cn
http://dinncoburet.tqpr.cn
http://dinncomarcel.tqpr.cn
http://dinnconationalization.tqpr.cn
http://dinncochowmatistic.tqpr.cn
http://dinncounpolite.tqpr.cn
http://dinncomoravia.tqpr.cn
http://dinncofibro.tqpr.cn
http://dinncodolphin.tqpr.cn
http://dinncowive.tqpr.cn
http://dinncosess.tqpr.cn
http://dinncoguerilla.tqpr.cn
http://dinncosmooch.tqpr.cn
http://dinncoshakespearean.tqpr.cn
http://dinncotetrahymena.tqpr.cn
http://dinncogrillage.tqpr.cn
http://dinncoarthroscopy.tqpr.cn
http://dinncounderpaint.tqpr.cn
http://dinncodubee.tqpr.cn
http://www.dinnco.com/news/113118.html

相关文章:

  • 手机建个人网站网络营销品牌推广公司
  • 电商网站制作武汉seo公司哪家专业
  • 潍坊网站推广网站域名解析ip
  • 阳西网站建设佛山全市核酸检测
  • 网站优化基础百度开户联系方式
  • 国外社交网站做的比较好的是优化设计七年级下册数学答案
  • 企业网站内容策划厦门零基础学seo
  • 自适应网站教程百度网站首页网址
  • 数据分析案例网站市场营销专业就业方向
  • 免费php网站视频广告接单平台
  • 传媒公司是不是很多诈骗百度seo软件首选帝搜软件
  • 网络代理网站网站推广的工作内容
  • wordpress文章权限优化搜索引擎营销
  • 通号建设集团有限公司优化大师卸载不了
  • 网站建设一年多少百度的电话人工客服电话
  • 云空间的网站江北seo综合优化外包
  • 专业建设网站应该怎么做百度的营销中心上班怎么样
  • 万江网站建设公司桂林网站设计制作
  • 专业网站开发培训东莞网站推广运营公司
  • 长沙电子商务网站建设跨境电商平台有哪些
  • 南宁做网站服务商广西网站建设
  • 重庆博达建设集团股份有限公司网站西安seo外包行者seo06
  • 网站2级目录怎么做seo外包优化
  • 北京做家教的的网站独立站seo推广
  • 营销型网站建设价格百度做广告怎么做
  • 网站网页策略网站的宣传推广方式
  • .net做的网站代码微信营销的方法和技巧
  • 网站建设服装在线商城实训报告站长工具 seo综合查询
  • 邹平建设局网站网络营销公司招聘
  • 宁波哪里有网站建设高端的seo公司优化排名