2016-01-29 132 views
1

我试图使用Spring Cloud Zuul服务器作为代理服务器,但是当我访问我的默认上下文时,它不会重定向到url目标。如何将Spring Cloud Zuul服务器设置为代理服务器

例如:

@EnableZuulServer 
@SpringBootApplication 
public class ZuulServerApp { 

    private static final Logger LOGGER = LoggerFactory.getLogger(ZuulServerApp.class); 

    public static void main(String[] args) throws Exception { 
     // Start Spring application 
     SpringApplication.run(ZuulServerApp.class, args); 

     LOGGER.warn("Startup completed and listening"); 
    } 
} 

application.properties

################### 
### Spring Boot ### 
################### 
server.port=8765 
spring.main.show-banner=false 

zuul.routes.resource.path=/** 
zuul.routes.resource.url=http://www.uol.com.br 
zuul.routes.resource.stripPrefix=true 

是否有任何配置丢失?

http://localhost:8765/ does not redirect to http://www.uol.com.br 

回答

2

添加@EnableZuulProxyZuulServerApp

你也可以不代理运行Zuul服务器,或 部分代理平台的选择性切换,如果你使用 @EnableZuulServer(而不是@EnableZuulProxy)。 添加到类型ZuulFilter的应用程序的任何豆将自动安装 ,因为它们与@EnableZuulProxy一样,但没有任何 自动添加代理筛选器。

在这种情况下进入Zuul服务器的航线 配置zuul.routes.*但没有服务发现和无 代理,所以“服务Id”和“网址”设置被忽略仍然规定。