question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swagger UI behind Service Fabric Reverse Proxy

See original GitHub issue

I have a Service Fabric stateless service hosted in Azure, using Service Fabric’s Reverse Proxy for access.

The working swagger.json URL looks like this: http://clustername.westeurope.cloudapp.azure.com/AppName/ServiceName/swagger/v1/swagger.json

However, when I try to load the swagger UI at http://clustername.westeurope.cloudapp.azure.com/AppName/ServiceName/swagger/ it 301 redirects to the internal path of the node handling the request http://clustername.westeurope.cloudapp.azure.com/01234567-0123-0123-0123-0123456789ab/012345678901234567/swagger/ which is not publicly accessible.

If I RDP onto the node, swagger UI on localhost does work: http://localhost:50874/01234567-0123-0123-0123-0123456789ab/012345678901234567/swagger

My startup uses the following configuration to find the json file relative to the swagger UI, which also works when not behind the reverse proxy: app.UseSwagger().UseSwaggerUI(c => c.SwaggerEndpoint("v1/swagger.json", "Service V1"));

The only x-forwarded headers I have available are: Host: 10.0.0.4:50874 X-Forwarded-For: 123.123.123.123 X-Forwarded-Host: clustername.westeurope.cloudapp.azure.com X-Forwarded-Proto: http

It seems that in 4.0 this was solved using ResolveBasePathUsing and in 5.0 this was solved using RootUrl. How can I solve this in Swashbuckle.AspNetCore? I have tried the PreSerializeFilter suggestion from Issue #68 with no luck.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
JDL440commented, Sep 15, 2017

I was able to make this work by seeting the basePath like this: .UseSwagger(c => { c.PreSerializeFilters.Add((swaggerDoc, httpReq) => swaggerDoc.BasePath = “/MyServiceApp/MyService”); })

0reactions
wswindcommented, Apr 29, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core–Running Swagger behind a reverse proxy
We have an ASP.NET Core Web API with OpenAPI(Swagger) integration enabled. This ASP.NET Core Web API was running behind a reverse proxy(Yarp in ......
Read more >
Swagger service url behind reverse proxy - Nick Lydon
This issue was seen in a dotnet application using swashbuckle and swagger-ui. If you're deploying apps behind a reverse proxy such as nginx ......
Read more >
Swashbuckle behind NGINX Reverse Proxy - Luke Rogers
After cloning the repo you can just run docker-compose up then open http://localhost:5100/api and you should see the swagger UI.
Read more >
Reverse proxy in Azure Service Fabric
Use Service Fabric's reverse proxy for communication to microservices from inside and outside the cluster.
Read more >
Fetch error FABRIC_E_TIMEOUT for SwaggerUI/swagger. ...
On my case, when I dig the problem in more depth, I found in my APIs, there are some objects used which don't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found