简体   繁体   English

将 url 路径重写为 API 的子域

[英]Rewrite url path to sub domain for API

I am using azure traffic manager but my api is on the main simian A record.我正在使用 azure 流量管理器,但我的 api 在主要的猿猴 A 记录上。 However I need a came to take advantage of Azure traffic manager.但是我需要一个来利用 Azure 流量管理器。

My question is can I do GET and POST from the current path to the API to a sub domain like below and if so what is the best approach to do this?我的问题是我可以从 API 的当前路径到如下子域的 GET 和 POST 吗?如果可以,最好的方法是什么?

Current API Path当前 API 路径

https://test.com/mobile/v1/api/.. . https://test.com/mobile/v1/api/..

New API Path (rewrite?)新 API 路径(重写?)

https://api.test.com/mobile/v1/api/.. . https://api.test.com/mobile/v1/api/..

Any performance issues with a solution?解决方案有任何性能问题吗? I have 500+ apps and can't manually update the url in each.我有 500 多个应用程序,无法在每个应用程序中手动更新 url。

Well several things here.这里有几件事。 If you have a wildcard A record, keep in mind you will need a wildcard SSL as well (but thats beside the point).如果您有通配符 A 记录,请记住,您还需要通配符 SSL(但那不是重点)。

Your gateway/proxy/load balancer should handle the routing/load balancing for the subdomains just as it would for 'WWW';您的网关/代理/负载均衡器应该像处理“WWW”一样处理子域的路由/负载均衡; after all 'WWW' is just another subdomain.毕竟“WWW”只是另一个子域。

As for how to setup/config, that is based on the gateway/proxy/load balancer you are using.至于如何设置/配置,这取决于您使用的网关/代理/负载均衡器。 See the config for 'routing' in the tool you are using.请参阅您正在使用的工具中的“路由”配置。

As I understand the question, you're looking for a scalable solution that allows N number of applications to use the same configuration value for the location of a service.据我了解,您正在寻找一种可扩展的解决方案,该解决方案允许 N 个应用程序使用相同的配置值来定位服务。

I would recommend using either service discovery or centralized configuration.我建议使用服务发现或集中配置。 The "centralized configuration" is somewhat self-explanatory, and service discovery is where your app knows the name of a service (eg: "the-api") and gets the location from a discovery server at runtime. “集中式配置”有点不言自明,服务发现是您的应用程序知道服务名称(例如:“the-api”)并在运行时从发现服务器获取位置的地方。

If you want to stick with a configuration-based approach, Azure has a configuration server that you could use, or you could use a Spring Cloud Config Server and the Steeltoe client for SCCS .如果您想坚持使用基于配置的方法,Azure 有 一个您可以使用的配置服务器,或者您可以使用Spring 云配置服务器用于 SCCS 的 Steeltoe 客户端

If you want to try out the service discovery approach, Steeltoe has options there for Netflix Eureka andHashiCorp Consul如果您想尝试服务发现方法,Steeltoe 可以选择Netflix EurekaHashiCorp Consul

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM