flask-restplus icon indicating copy to clipboard operation
flask-restplus copied to clipboard

HTTP Header Host and swagger.json

Open FloLaco opened this issue 4 years ago • 1 comments

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

  • Python version : Python 2.7.16
  • Flask version : Flask 1.1.1
  • Flask-RESTPlus version 0.13.0
  • Other installed Flask extensions

FloLaco avatar Mar 26 '20 12:03 FloLaco

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

carscan avatar Apr 04 '20 20:04 carscan