Search code examples
javaspringreverse-proxyundertow

Implement an Undertow reverse proxy that behaves like nginx


For development purposes, not everyone can install nginx on their machines (like our developers on Windows environments), but we want to be able to do a reverse proxy that behaves like nginx.

Here's our very specific case:

We would like to serve both services from http://0.0.0.0:8080

So we would like to map it like this:

That way it works like nginx with url rewrite reverse proxying.

I checked out the Undertow source code and examples, and even this specific example: Reverse Proxy Example, but this is a load balancer example, I haven't found any example that covers what I need.

Also, I know Undertow is capable of this, because we know we can configure WildFly to cover this specific case without issues through the Undertow component configuration, but we would like to implement it ourselves as a lightweight solution for local development.

Does anyone know of an example to do this? or any documentation that has enough info to implement this? because I've also read Undertow's documentation on reverse proxying and it's not helpful at all.

Thanks


Solution

  • As per M. Deinum's comment suggestion, I'll use Zuul Spring Boot component instead of trying to do this with Undertow, as it's more fit for this task.

    Here's a link on a tutorial to do this:

    https://spring.io/guides/gs/routing-and-filtering/

    Hope this helps anyone else, as this is a pretty common case, and I didn't know about Zuul on Spring Boot.