Java 如何将SpringCloudZuul服务器设置为代理服务器
我尝试使用SpringCloudZuul服务器作为代理服务器,但当我访问默认上下文时,它不会重定向到url目标 例如:Java 如何将SpringCloudZuul服务器设置为代理服务器,java,spring,spring-boot,spring-cloud,Java,Spring,Spring Boot,Spring Cloud,我尝试使用SpringCloudZuul服务器作为代理服务器,但当我访问默认上下文时,它不会重定向到url目标 例如: @EnableZuulServer @SpringBootApplication public class ZuulServerApp { private static final Logger LOGGER = LoggerFactory.getLogger(ZuulServerApp.class); public static void main(Str
@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
:
您还可以在不使用代理的情况下运行Zuul服务器,或者打开
如果使用代理平台,则有选择地使用代理平台的部分
@EnableZuulServer
(而不是@EnableZuulProxy
)。你要什么豆子
添加到将安装的应用程序类型zuumFilter
自动,就像使用@EnableZuulProxy
一样,但不使用任何
正在自动添加的代理筛选器
在这种情况下,进入Zuul服务器的路由仍然由
正在配置zuul.routes.*
,,但没有服务发现和
代理,因此“serviceId”和“url”设置被忽略