简体   繁体   中英

Rewrite url path to sub domain for API

I am using azure traffic manager but my api is on the main simian A record. However I need a came to take advantage of Azure traffic manager.

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?

Current API Path

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

New API Path (rewrite?)

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.

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).

Your gateway/proxy/load balancer should handle the routing/load balancing for the subdomains just as it would for 'WWW'; after all 'WWW' is just another subdomain.

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.

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.

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 .

If you want to try out the service discovery approach, Steeltoe has options there for Netflix Eureka andHashiCorp Consul

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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