Don't route specific route in Ocelot

246 views Asked by At

I have a load balancer/API. This Process runs on 3 ports 5000, 5001 and 5002. Every request that comes in on ports 5000 and 5001 with the base route /api should be routed to the specified hosts. But there is a single controller on port 5002 with the route /page (Just an example name) that shouldn't be forwarded but handled whithin the load balancer/API.

http://localhost:5000/api -> forward
https://localhost:5001/api -> forward
https://localhost:5002/page -> Don't forward

So the configuration for the /api route works like expected so I'm not going to include that here. For the /page route I tried:

{
    "UpstreamPathTemplate": "/secrets",
    "UpstreamScheme": "https",
    "UpstreamHostAndPorts": [
        {
            "Host": "localhost",
            "Port": 5002
        }
    ],
    "DownstreamPathTemplate": "/secrets",
    "DownstreamScheme": "https",
    "DownstreamHostAndPorts": [
        {
            "Host": "localhost",
            "Port": 5002
        }
    ],
}
1

There are 1 answers

0
adkop On BEST ANSWER

How José Ramírez pointed it out in his comment, the order of the middlewares has to be correct.

In this case, you have to use this order

app.MapControllers()
app.UseOcelot().Wait()