ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.32k stars 1.63k forks source link

This page isn’t workinglocalhost is currently unable to handle this request. HTTP ERROR 502 #131 #1356

Closed gopi-rm closed 5 months ago

gopi-rm commented 3 years ago

Describe the bug I got error on publishing gateway on iis default port

my swagger json { "Routes": [ { "DownstreamPathTemplate": "/api/{everything}", "UpstreamPathTemplate": "/api/cinema.svc/{everything}", "DownstreamHostAndPorts": [ { "Host": "localhost", "Port": 8100 } ], "SwaggerKey": "cinema.svc" } ] },{ "SwaggerEndPoints": [ { "Key": "cinema.svc", "Config": [ { "Name": "Cinema API", "Version": "v1", "Url": "http://localhost:8100/swagger/v1/swagger.json" } ] } ] } ] }

startup.cs public void ConfigureServices(IServiceCollection services) { services.AddOcelot().AddAppConfiguration(); services.AddSwaggerForOcelot(Configuration); services.AddControllers(); services.Configure(options => { options.AutomaticAuthentication = false; }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" }); }); }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {           
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseHttpsRedirection();           

        app.UseRouting();

        app.UseAuthorization();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });
        app.UseStaticFiles();

        app.UseSwaggerForOcelotUI().UseOcelot().Wait();
    }

.

To Reproduce If it is a possible attache:

  1. Original downstream swagger.json.
  2. Ocelot ReRoutes configuration.
raman-m commented 5 months ago

We don't support Swagger! And we don't recommend to deploy into IIS environment!