New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swagger UI behind Service Fabric Reverse Proxy #427
Comments
I am running into a similar situation running behind HAProxy and utilizing URL rewriting features and can't figure out to force Swashbuckle.AspNetCore to keep the original request URL structure. |
I tried a couple of config options but could not get Swagger UI working behind a reverse proxy. Appreciate any guidance on how to set the configs such that Swagger UI loads and can make requests to the service (Try It out options) correctly with reverse proxies. |
I'm also looking for the "new" |
I was able to make this work by seeting the basePath like this: |
See my comments here - #380 (comment) Easiest way to support reverse proxies! |
Please re-read the original post then reopen and fix this. This is already using a relative path. It finds the JSON file but then 301 redirects to an internal IP address, which is not available from outside the reverse proxy. |
Fair enough - there's a couple of issues mixed up in this one. @ghelyar - this being FREE n open source n all, perhaps you could dig a little deeper and propose a potential fix 😉 |
Dup of #662 I'm going to close this in favor of the above duplicate because it's detailing of the problem is a little clearer. |
@ghelyar - which version of Swashbuckle are you using |
I used relative URL to fix this, see this comment: |
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.
The text was updated successfully, but these errors were encountered: