I am playing around with Zuul but there seems to be something fundamental I don't understand.
Per the documentation (http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html), The following Zuul configuration should cause all http calls to "/myusers" to be forwarded to the "users" service.
zuul:
routes:
users: /myusers/**
I have a similar scenario but it simply doesn't work. My configuration is:
zuul:
route:
stores: /california/**
The service Id is "stores" and it has a URL called "/hello". When I hit:
http://localhost:8765/california/hello,
I get the Spring Boot 404 error message. However, things work very well if I replace california with stores, resulting in the following configuration:
zuul:
route:
stores: /stores/**
In this case, if I call
http://localhost:8765/stores/hello,
Things work just fine. So, it looks as if the prefix of the URL has to match the ID of the service. Is that the expected behavior? What am I missing?
I am using the Zuul 1.0.0.BUILD-SNAPSHOT.
On a aisde note, I did notice that the discovery client is now built in into Zuul. Is there a way to disable it if I don't want to run Eureka?
Oh my goodness, it should of course be
zuul:
routes:
instead of
zuul:
route:
Related
In my application I am using ingress/nginix its conflicts my backend API route.
ingress file contains default UI route using regex
/()(.*)
Above is default route and based on it it loads default page of UI
UI route -
/management
At backend .Net controller level I have route prefix like in b
/api/management
For backend API, In ingress I have defined route like
/api/management()(.*)
UI is rendered from /management route from management-ui-service
While calling backend API from UI we are calling backend api endpoints with http://domain/api/management/XXXX
It returns 404 with above API path,but while we call API with http://domain/api/management/api/management/XXXX (need to pass multiple time end point - /api/management) it works
How we can call it with single endpoint like
http://domain/api/management/XXXX
This may be well related to regex in path put there for no good reason.
I use ingress this way and so far it works exactly as I expect it:
- backend:
service:
name: app-api
port:
number: 80
path: /api-manage/
pathType: Prefix
- backend:
service:
name: app-ui
port:
number: 80
path: /manage/
pathType: Prefix
This way I can refer to https://api.mysite.io/manage or https://api.mysite.io/api-manage/ and land exactly where I'm supposed to.
Yes, it is formatted different than your example, but you should be able to adapt it to your configuration.
This isn't my area. Sorry if this is a simple question, but I've been fussing with this and looking at the express-http-proxy documentation for hours and can't come up with a solution.
I have an API I didn't build, and can't access the logs for, but it works.
https://dev.server.com/jsp/app/api/user/profile/saveLastLogin
I would like to use express-http-proxy so I can develop locally without CORS issues
app.use('/api', proxy('https://dev.server.com/jsp/app', {
https: false
}));
My problem is I don't seem to be hitting the right endpoint.
is http://localhost:8080/api/user/profile/saveLastLogin hitting
https://dev.server.com/jsp/app/api/api/user/profile/saveLastLogin OR
https://dev.server.com/jsp/app/user/profile/saveLastLogin OR
https://dev.server.com/api/user/profile/saveLastLogin OR...
I've tried all sorts of configurations. Removed and added back slashes. Looked at the documentation and gone over a bunch of the available options, and tried configuring it asynchronously.
Is there an option that will logout or in some other way let me know what endpoint my proxy is proxying to?
I have a kubernetes cluster and I am using traefik ingress controller to route traffic to deployments inside the kubenetes cluster.
I am able to use ingress.kubernetes.io/rewrite-target annotation to change the incoming request path to the one expected by the backend.
For example : /star is transformed to /trek by the rewrite target annotation and the request gets routed to /trek and backend processing is successful.
What I want to know is if there is a way to change response header so that /trek gets changed back to /star?
Did you get an answer to this? It looks like similar functionality is available in Apache Traffic Server: https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/header_rewrite.en.html, but would be good to have it in traefik
The functionality that does this is modifiers and specifically ReplacePath. Here is a similar answer with some examples.
When using history mode in vue-router the documentation is suggesting a pretty dodgy way to get around some of the limitations it has.It suggests a server-side configuration that catches all URLs that could be a client-side route and rewriting to root (/) so the client-side app is delivered. And then another catch-all route to a 404 component in the client-side router if no routes match.
Problem is, this will mean your server is returning 200 OK status codes to crawlers/indexers for basically every URL, specifically ones that don’t technically exist.
My thoughts so far:
Use IIS <rewriteMap> to list the valid client-side route patterns I have and use that for matches instead of a catch-all on everything not a file/dir.
Problem: pain to manage in tandem with client-side routes.
Routes defined in server config and handed to client-side router via an api endpoint for registration
Problem: setting up an API when you just want to host a static app is a pain.
Any other suggestions?
Let's say I have a Foo service that accepts requests like:
http://foo-service/bar/baz
...and returns HATEOAS-style responses:
{
"self": "http://foo-service/bar/baz"
}
(Yes it should be links, href, etc - I'm simplifying for this question).
Now suppose I want to put that behind a reverse-proxy that also rewrites URI paths:
http://router/foo/bar/baz
(Here, I'm detecting the path starts with /foo/..., and so the reverse-proxy knows what service to route to. I would expect the self link to be "http://router/foo/bar/baz", even though the reverse-proxy actually made a request to http://foo-service/bar/baz).
I know about the Host: and X-Forwarded-Host: headers for specifying what the original request host was.
What is the correct header (or more generally, what is the correct way) for specifying the original path?
Finally found a possible answer: it seems to be X-Forwarded-Prefix.
eg: HATEOAS paths are invalid when using an API Gateway in a Spring Boot app