如何解决Spring Zuul重定向不适用于外部网址
请您告知为什么mu Zuul重定向不起作用。
application.properties
spring.application.name=netflix-zuul-api-gateway-server
application.yml
zuul:
routes:
google:
path: /google/**
url: https://www.google.com/
stripPrefix: true
bootstrap.properties
management.endpoints.web.exposure.include=*
management.endpoint.routes.enabled=true
management.endpoint.filters.enabled=true
server.port=8765
NetflixZuulApiGatewayServerApplication
@SpringBootApplication
public class NetflixZuulApiGatewayServerApplication {
public static void main(String[] args) {
SpringApplication.run(NetflixZuulApiGatewayServerApplication.class,args);
}
@Bean
public Sampler defaultSampler(){
return Sampler.ALWAYS_SAMPLE;
}
ZuulLoggingFilter
@Component
public class ZuulLoggingFilter extends ZuulFilter{
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public boolean shouldFilter() {
return true;
}
@Override
public Object run() {
HttpServletRequest request =
RequestContext.getCurrentContext().getRequest();
logger.info("request -> {} request uri -> {}",request,request.getRequestURI());
return null;
}
@Override
public String filterType() {
return "pre";
}
@Override
public int filterOrder() {
return 1;
}
}
版本:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
来自http:// localhost:8765 / actuator / routes / details的响应:
{
"/google/**": {
"id": "google","fullPath": "/google/**","location": "https://www.google.com/","path": "/**","prefix": "/google","retryable": false,"customSensitiveHeaders": false,"prefixStripped": true
}
}
为http:// localhost:8765 / google / try获取404
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。