如何设置 Spring Cloud Zuul 服务器作为代理服务器
How to setup Spring Cloud Zuul server as proxy server
我尝试使用 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
将 @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.
我尝试使用 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
将 @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 typeZuulFilter
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.