- cd greetings
- run
./gradlew bootRun
- greetings service will start at port 8080
- cd spring-zuul-redirect
- run
./gradlew bootRun
- spring zuul proxy service will start at port 9000
curl --location --request GET 'http://localhost:9000/api/greet/john'
will return 404.This is because, the zuul proxy is not able to resolve the /hello/john url from the *redirect location path* to any of its routes. Note : Even though the LocationRewriteFilter bean has been added in the spring boot application class (SpringZuulRedirectApplication.java), the LocationRewriteFilter has been disabled in the application.yml.
- x-forwarded-prefix header (refer spring cloud doc):
curl --location --request GET 'http://localhost:9000/api/farewell/john'
should returnBye john
- LocationRewriteFilter (refer spring doc):
- Remove
LocationRewriteFilter
related config from zuul proxy service's application.yml and restart the zuul proxy service. curl --location --request GET 'http://localhost:9000/api/greet/john'
should return Hello John- Caveat of using
LocationRewriteFilter
is thatAs mentioned in the docs, this filter acts on the Location header of ALL 3XX response codes, which may not be appropriate in all scenarios, such as when redirecting the user to an external URL.
- This can be tested by running
curl --location --request GET 'http://localhost:9000/api/go-to-google'
. This will return a 404 not found error, stating "/" is not found.
- This can be tested by running
- Remove