'Ocelot not working with .NET 6 running on docker container
I'm trying to configure Ocelot but i'm getting a 404. Here's my Program.cs:
using Microsoft.OpenApi.Models;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
var builder = WebApplication.CreateBuilder(args);
builder.Host.ConfigureAppConfiguration(app => app.AddJsonFile("configuration.json"));
builder.Services.AddOcelot(builder.Configuration);
builder.Services.AddMvc();
builder.Services.AddSwaggerGen();
builder.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Title = "Ocelot",
Version = "v1",
Description = "Ocelot."
});
});
var app = builder.Build();
app.UseSwagger()
.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Ocelot");
});
app.UseOcelot().Wait();
app.Run();
My configuration.json:
{
"ReRoutes": [
{
"DownstreamPathTemplate": "api/v1/Catalog/items/{id}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "catalog.api",
"Port": 80
}
],
"UpstreamPathTemplate": "/v1/c/{id}",
"UpstreamHttpMethod": [ "POST", "PUT", "GET" ]
}
],
"GlobalConfiguration": { "BaseUrl": "https://localhost:5202" }
}
The request https://localhost:5202/v1/c/1 returns a 404.
The host catalog.api is my catalog microservice running on another docker container and its working, i've tested calling by its own port: http://localhost:5101/api/v1/Catalog/items/1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
