Burgyn / MMLib.SwaggerForOcelot

This repo contains swagger extension for ocelot.
MIT License
349 stars 93 forks source link

Virtual Directory configuration IIS doesn't work UpstreamPathTemplate 404 not found #269

Open IgnacioCastro0713 opened 1 year ago

IgnacioCastro0713 commented 1 year ago

Screenshot_2 I'm trying to configure my Gateway and two microservices but they don't work when they are in virtual directories each. all these are on the same server

folder structure of IIS:

├── DataWarehouseService
├── AgileService
└── Gateway
    └── Ocelot
        └── ocelot.json

this is my ocelot.json

{
  "GlobalConfiguration": {
    "BaseUrl": "https://domain.com/Gateway"
  },
  "Routes": [
    {
      "DownstreamPathTemplate": "/agile/api/v1/{everything}",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 7122
        }
      ],
      "UpstreamPathTemplate": "/agile/v1/{everything}",
      "UpstreamHttpMethod": ["GET", "POST", "PUT", "DELETE"],
      "SwaggerKey": "agile"
    },
    {
      "DownstreamPathTemplate": "/DataWarehouse/api/v1/{everything}",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 7082
        }
      ],
      "UpstreamPathTemplate": "/DataWarehouse/v1/{everything}",
      "UpstreamHttpMethod": ["GET", "POST", "PUT", "DELETE"],
      "SwaggerKey": "DataWarehouse",
      "VirtualDirectory": "/DataWarehouseService"
    }
  ],
  "SwaggerEndPoints": [
    {
      "Key": "agile",
"TakeServersFromDownstreamService": true,
      "Config": [
        {
          "Name": "PLXS.Microservice.Agile",
          "Version": "v1",
          "Url": "https://domain.com/AgileService/swagger/v1/swagger.json"
        }
      ]
    },
    {
      "Key": "DataWarehouse",
"TakeServersFromDownstreamService": true,
      "Config": [
        {
          "Name": "DataWarehouse EndPoints",
          "Version": "v1",
          "Url": "https://domain.com/DataWarehouseService/swagger/v1/swagger.json"
        }
      ]
    }
  ]
}

code configuration:


  app.UsePathBase("/Gateway");

 app.UseSwaggerForOcelotUI(options =>
        {
            if (app.Environment.IsDevelopment()) return;

            //IIS Config
            options.PathToSwaggerGenerator = "/swagger/docs";
            options.DownstreamSwaggerEndPointBasePath = "/Gateway/swagger/docs";
            options.ServerOcelot = "/Gateway";
        });
IgnacioCastro0713 commented 1 year ago

My configuration works perfectly locally but there I’m not using virtual paths just run the 3 projects as usual