使Zuul使用与Spring Boot应用程序不同的上下文路径

问题描述

我正在使用Zuul将对图像的请求从我的Spring Boot应用转发到图像优化Web服务器(thumbor)。在localhost:8080上运行的spring服务器使用/api的上下文路径。然后Zuul将请求从/images/**转发到运行在localhost:3000上的thumbor服务器。

所以要获取图像,我必须localhost:8080/api/images/**,但是我想要localhost:8080/images/**

我尝试了zuul提供的servlet路径配置,但是它在像localhost:8080/api/zuul/images/**这样的spring boot的servlet上下文路径之后开始。

这是我的配置。

application.yml

...
server:
    base-url: http://localhost:8080/api/
    port: 8080
    servlet:
        context-path: /api
...
zuul:
    routes:
        thumbor:
            path: /images/**
            url: http://localhost:3000
    servlet-path: /zuul
...

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)