There goes our scenario.
From client browser the initial request would look like below.
http://host:port/app-name/microservice-path/api-path
e.g.
http://localhost:8080/MySec/customerservice/customers
application.properties
zuul.routes.customer-service.path=/customerservice/**
zuul.routes.customer-service.service-id=customer-service
My Requirement
We want to skip the application name at zuul end, and want zuul to look for a service id for "customerservice" and NOT "MySec"
I can't use zuul.prefix, because the application name could be anything, and its a must that we have the applicaiton name at the context root level to perform some actions in some of the layers before it reaches gateway.
What do you mean that the "application name could be anything" ? Is that the Zuul application name? What is the application name used for?
We are running a multi portal web application. Users will launch different applications which would make use of the same zuul gateway to invoke underlying APIs. And it's important for the application name to be the context root for all URLs executed from that application.
E.g.
http://localhost:8080/MySec/customer service/customers
http://localhost:8080/MyRoam/customer service/customers
If there is an option like zuul.prefix=/*
might work for me..
I even tried writing a pre filter to skip the application name, but doesn't seem to work as context.put("requestURI", "changedURL") is actually the path of the destination. But not able to modify the url before zuul starts looking for service Id.
I am still not clear on what you want to achieve . Can you please clarify that . As you said u had written a pre filter where you were changing the requestUri , check if u have set filtering order after PreDecoration Filter. Because , if you have not set it to filter after PreDecoration Filter , ur changes to requestURI wont take effect and would be simply overwritten by PreDecoration Filter when it runs.
Yes I made the pre-order to be higher than the decoration filter.
Let me reword my issue.
As mentioned above below is how the routes are configured.
zuul.routes.customer-service.path=/customerservice/**
zuul.routes.customer-service.service-id=customer-service
As per above configuration for the routes to work properly zuul must recieve the request url as
http://localhost:8080/customer service/customers
But the request will not be like above, as I need to have the applicationName(something specific to my business domain) to be the first in the path (http://localhost:8080/appName/** as I have so many rules and validations done at various levels in the system based on the application name in the traffic managers, web servers etc. So I had couple of options,
I would most likely choose options 1. Option 2 is not possible as far as I know. Option 3 should work, but I would rather not add custom code if I dont need to.
Thanks. Yes option 1 looks sensible. Also I think option 2 is a nice to have feature..
However, I am looking at writing custom code at zuul for code maintainability. Initially I thought should be a simple job..
any help is highly appreciated..
Let me know if you need help with writing the filter. If its not working for you provide a sample that shows it not working so we have something to work from.
Hi
Im having a relative problem that with a filter im not able to solve.
I have to add a Zuul server that receive SSL request from the port 443, but working witha previous web that was working in the SSL with a hhtps://localhost:443/WEB_OLD.
We have thought to move the old web to a different port to set in the 443 the Zuul ones. I added the properties to zuul.
zuul:
#ignoredServices: ''
routes:
web:
path: /WEB_OLD/*
url: http://localhost:8081/
But i have the problem that in the browser show me "http://localhost:8081/" and i want it looking as "https://localhost:443/".
You know how to implement it with a filter?
Thanks!!!
@Gulivert your problem seems difference, can you please open a separate issue?
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Most helpful comment
I would most likely choose options 1. Option 2 is not possible as far as I know. Option 3 should work, but I would rather not add custom code if I dont need to.