Spring Data Rest - proxy path not including a link path

I proxy the Spring REST backend like this:

Backend: http://backend:8080

Proxy server:

localhost:3000/api/backend -> http://backend:8080

If I look locally to a proxied endpoint, it proxies the request, however the links do not include the proxy path, i.e.

GET localhost:3000/api/backend/people

"href": "http://localhost:3000/people"

I expect this to be:

"href": "http://localhost:3000/api/backend/people"

Is there any way to fix this?

Thank!

+4
source share
1 answer

You should look at the headers x-forwarded-*that your proxy adds to the request.

If your proxy server’s backend request contains the x-forwarded-prefix=/api/backendspring header , it will pick up the prefix and add it to the generated link.

You do not specify which proxy server you are using, so I cannot say if your proxy supports the header x-forwarded-prefix.

+4

All Articles