spring-cloud / spring-cloud-netflix

Integration with Netflix OSS components
http://cloud.spring.io/spring-cloud-netflix/
Apache License 2.0
4.87k stars 2.44k forks source link

adding dynamic route to zuul #1359

Closed nmorado closed 8 years ago

nmorado commented 8 years ago

not sure if this one is currently supported.

need to add (maybe also remove, or update) existing routes to a running zuul proxy.

is this currently possible? if not - any ideas on how we might achieve the same without really restarting your app and updating mapping in a properties file?

thanks

aivans commented 8 years ago

https://github.com/spring-cloud/spring-cloud-netflix/issues/706

damozhiying commented 8 years ago

@aivans how to dynamic route and add route info not start app

@RequestMapping("/reDirect")
public String reDirect(HttpServletRequest request) {
  ZuulRoute route_cy=new ZuulRoute();
  route_cy.setId("erp_cy");
  route_cy.setPath("/erp_cy/**");
  route_cy.setUrl("http://169.254.50.169:8081");
  discoveryClientRouteLocator.addRoute(route_cy);
  ZuulRoute route_gwzx=new ZuulRoute();
  route_gwzx.setId("erp_gwzx");
  route_gwzx.setPath("/erp_gwzx/**");
  route_gwzx.setUrl(" http://localhost:9000");

  discoveryClientRouteLocator.addRoute(route_gwzx);

  String id=request.getSession().getId();
  return "redirect:/erp_gwzx/";
}
damozhiying commented 8 years ago

@aivans first ,i use ui gateway to offer one point endpoint services ,at the same time ,the backends service machine can't be access by the Internet, when users open the browser the ui server route to the sso system,when login success,the sso server redirect to the ui gateway ,the ui gateway according to the session id get user info from redis ,now the requirements is according to the userID, the ui gateway route to different pc get ui pages. the first problem is how i get zuul route config info from database the second is how ui gateway according to userid add route to zuul and zuul route to diff pc,(because some service such as http://192.168.1.22, there not the context, at the same time can't use http Re-direct 302, ) ,dynamic add the zuul route and bypass to the diff pc get ui page

spencergibb commented 8 years ago

Duplicates #706 & #705