Consumer base_uri field filled with API gateway host if needed
See original GitHub issueWhen a new consumer is created, the base_uri
returned in the HTTP body by the bridge contains the address to be used by the client for subsequent consumer operations.
The bridge uses the HTTP “Host” header for getting the address that the HTTP client has to call.
Using an API gateway (i.e. 3scale) in front of the bridge changes the scenario.
The HTTP client is using the API gateway address and it should be used in the future requests but because the bridge isn’t aware that the request comes from an API gateway, just use the “Host” header and … the client gets the bridge address instead of the API gateway one in the base_uri
field.
For example, client sends request to:
http://gateway.192.168.1.9.nip.io:8080/consumers/my-group
but the base_uri
in the JSON response is:
http://bridge.192.168.1.9.nip.io:8083/consumers/my-group/instances/consumer1
On solution could be having the API gateway adding a custom header in each request like API_GATEWAY_HOST
so that the bridge can use this one instead of the default “Host” as base address in the base_uri
.
@tombentley @scholzj @kyguy @stanlyDoge any thoughts?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
The issue was fixed by the 3scale team now it’s possible to create a header policy at 3scale configuration level to add the three
X-Forwarded
headers so that the bridge can use them for building thebase_uri
field or if not present continue to useHost
as today.So using 3scale I was able to use a header policy to add
X-Forwarded-Host
getting the Nginx$host
variable exposed via Liquid. Currently, there is no way of getting the scheme and the port. I had a call with @eloycoto from 3scale team and he opened an issue for adding more information.https://github.com/3scale/APIcast/issues/1079
At the end, I will be able to use
X-Forwarded-Host
,X-Forwarded-Proto
andX-Forwarded-Port
even if the last one is completely custom because doesn’t exist, in the Mozilla documentation neither. While Eloy works on having them available I can change the bridge accordingly.