Search code examples
restspring-bootservlet-filtersspring-cloudnetflix-zuul

Zuul routing doesn't work, gives 404 : Spring Boot+ Cloud+ Zuul


I am working on a flow where I have ng4+boot app running on https://host_a:8080 and a backend service at https://host_b:8080 with some APIs.

I have RestController/Path at both the hosts, i.e. I need some urls to hit localhost (host_a) and others to host_b.

In application.yml, I have tried almost all possible combinations of Zuul routes but still getting 404 for all host_b rest APIs. host_a APIs work well.

Note: We have this working when there is no rest API on host_a and no custom filter on host_a.

  1. Is there something wrong working with filter? I don't see any log from zuul filter now after I added this controller to host_a

I am aware that I can use forward property to route to localhost which works well. But somehow host_b rest all gives 404 error.

My implementation requirements-

  1. http://host_a:8080/api/abc/user to hit at localhost i.e. host_a

  2. http://host_a:8080/api/xyz/getall to hit at host_b

  3. Important- Need a custom zuul filter which adds certain headers to request before it's routed to host_b as explained in point 2. - Already at place, but cannot see logs inside it now.

What I tried already-

zuul: 
  routes:
      xyz:
        path: /api/xyz/**
        url: http://host_b:8080/api/xyz

I tried almost everything, using prefix, strip-prefix, only host in url, using forward for local routing, etc. Nothing works.

Kindly help me with the possible causes I may be ignoring or if missing something?

Thanks in advance.


Solution

  • Finally, I was able to resolve issues.

    1. I had to change jersey @Path to spring @RestController
    2. Changed Zuul Filter order from 1 to 999.

    Works well now.