【问题标题】:How to setup Spring Cloud Zuul server as proxy server如何将 Spring Cloud Zuul 服务器设置为代理服务器
【发布时间】:2016-05-07 17:50:46
【问题描述】:

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

例如:

@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

【问题讨论】:

    标签: java spring spring-boot spring-cloud


    【解决方案1】:

    @EnableZuulProxy 添加到您的ZuulServerApp

    你也可以在没有代理的情况下运行 Zuul 服务器,或者打开 有选择地代理平台的一部分,如果你使用 @EnableZuulServer(而不是 @EnableZuulProxy)。你喜欢的任何豆子 添加到ZuulFilter 类型的应用程序将被安装 自动,就像它们与 @EnableZuulProxy 一样,但没有任何 自动添加代理过滤器。

    在这种情况下,进入 Zuul 服务器的路由仍然由 配置zuul.routes.*,但是没有服务发现也没有 代理,因此忽略“serviceId”和“url”设置

    【讨论】:

      猜你喜欢
      • 2015-01-18
      • 2017-11-21
      • 2014-03-30
      • 2017-05-21
      • 2016-10-11
      • 2017-10-04
      • 2017-09-07
      • 1970-01-01
      • 2015-07-31
      相关资源
      最近更新 更多