noirbizarre / flask-restplus

Fully featured framework for fast, easy and documented API development with Flask
http://flask-restplus.readthedocs.org
Other
2.74k stars 506 forks source link

HTTP Header Host and swagger.json #789

Open FloLaco opened 4 years ago

FloLaco commented 4 years ago

I suspect that swagger is using the HTTP Header "Host xxxxx.com" to return the swagger.json file. I can't find anything on the doncumentation to avoid this behavior.

Context

Info: I've change url in the exemple, so you may find screenshot and text different I've an application deployed on a container behind 2 reverse proxy (one in the cloud env and one on kubernetes). My URL application deployment on the kubernetes reverse proxy is (for exemple) : test1.dsrauto.prj.kube.test.com

I would like to expose my application with this url : network-api-pprod.test.com (more easy to use) So, on the second revers proxy (HA Proxy), I've configured to listen on network-api-pprod.test.com and send trafic to the other reverse proxy (the kube). But for it can work, I've to add an header into http-request, like this (don't look the format, I'm justing using api to configure HAProxy):

{
  "fqdn": "network-api-pprod.test.com",
  "mode": "http",
  "backend": [
    "http-request set-header Host test1.dsrauto.prj.kube.test.com",
    "server srv x.x.x.x:443 weight 1 maxconn 100 ssl verify none check"
  ],
  "subdomains": "false"
}

If you look the network inspection, my browser is trying to get all swagger resource with the correct url (network-api-pprod.test.com) but only the swagger.json is trying to get on the HTTP Header Host url (test1.dsrauto.prj.kube.test.com).

image

Environment

carscan commented 4 years ago

@FloLaco is there any temporary fix available to avoid this from happing?