gpt4 book ai didi

java - 如何设置 Spring Cloud Zuul 服务器作为代理服务器

转载 作者:行者123 更新时间:2023-11-30 03:04:40 25 4
gpt4 key购买 nike

我尝试使用 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");
}
}

应用程序属性

###################
### 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

最佳答案

@EnableZuulProxy添加到您的ZuulServerApp:

You can also run a Zuul server without the proxying, or switch on parts of the proxying platform selectively, if you use @EnableZuulServer (instead of @EnableZuulProxy). Any beans that you add to the application of type ZuulFilter will be installed automatically, as they are with @EnableZuulProxy, but without any of the proxy filters being added automatically.

In this case the routes into the Zuul server are still specified by configuring zuul.routes.*, but there is no service discovery and no proxying, so the "serviceId" and "url" settings are ignored.

关于java - 如何设置 Spring Cloud Zuul 服务器作为代理服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35093929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com