Search code examples
spring-bootnetflix-zuul

Spring cloud Zuul reverse proxy routing not working with versioned and context path specified rest application


Created a spring boot application and sets context path and version. Then added configurations for zuul proxy for routing. Me refer the spring example Routing and Filtering. Only difference in application.properties is added contextPath and version. Also enabled zuul proxy using @EnableZuulProxy annotation. But the routing is not working. When I remove the version and context it works.

application.properties file

server.port=8080
server.servlet.context-path=/app1
version=v1
zuul.routes.foos.path=/api/**
zuul.routes.foos.url=http://localhost:8081/app2/v1/

Solution

  • Finally resolved the issue. Forgot to add version in zuul path. Need to add version also in zuul path.

    application.properties

    server.port=8080
    server.servlet.context-path=/app1
    version=v1
    zuul.routes.foos.path=/v1/api/**
    zuul.routes.foos.url=http://localhost:8081/app2/v1/