This project is an implementation of a reverse proxy using either Spring Cloud Starter Netflix Zuul or Spring Cloud Starter Gateway (MVC or Webflux).
A reverse proxy is a type of server that acts as an intermediary between clients and servers, receiving requests from clients and forwarding them to the appropriate servers. The reverse proxy can be used for various purposes, such as load balancing, authentication and authorization, protection from cyber attacks, masking the server's IP address, and traffic compression. This increases security and improves scalability of online applications.
This repository contains three different Spring Boot projects for reverse proxy a Grafana Server:
spring-cloud-starter-netflix-zuul
spring-cloud-starter-gateway-mvc
spring-cloud-starter-gateway-webflux
This project demonstrates how to use Zuul as a reverse proxy in a Spring Boot application. It includes a simple example of routing incoming requests to different microservices based on the URL path.
The library spring-cloud-starter-netflix-zuul has a limitation related to web sockets. I overcame it, creating a java websocket reverse proxy.
This project showcases the use of Spring Cloud Gateway MVC for reverse proxying in a Spring Boot application. It includes examples of request routing, request filtering, and customizing the response for incoming requests.
In order to use the library spring-cloud-starter-gateway combined with MVC it is necessary to introduce in the properties file:
...
spring.main.web-application-type=reactive
...
This property allows you to overwrite the beans that have been declared with the same name.
This project demonstrates the use of Spring Cloud Gateway WebFlux for reverse proxying in a Spring Boot application. It includes examples of request routing and filtering, and customization of the response for incoming requests using WebFlux.
- Java 11 or later
- Docker installed on your system
To run the project, follow these steps:
- Clone the project repository to your local machine.
git clone https://github.com/riccardobek/spring-reverse-proxy.git
- Navigate to the project directory.
cd spring-reverse-proxy
- Build the Docker images of the project.
docker-compose up
-
Access the applications through the following endpoint:
-
spring-cloud-starter-netflix-zuul - http://localhost:8080/
open http://localhost:8080/
-
spring-cloud-starter-gateway-mvc - http://localhost:8081/
open http://localhost:8081/
-
spring-cloud-starter-gateway-webflux - http://localhost:8082/
open http://localhost:8082/
-
This project is licensed under the MIT License. See LICENSE for more information.
This project provides a starting point for building a reverse proxy using either Zuul or Gateway in a Spring Boot application. You can customize it to meet your specific requirements.