Client sent Host header is not being forwarded to API

520 views
Skip to first unread message

Erik Azar

unread,
Apr 6, 2016, 3:41:34 PM4/6/16
to Kong
I'm having trouble with an API I have configured. I need to have Kong preserve the Host header I send and forward to my upstream_url. That is not happening though and Kong is substituting the upstream_url scheme:host:port instead. I'm running Kong 0.7.0.

Here is my current API end config in Kong:

{
  "data": [
    {
      "upstream_url": "http://lb-api.mycompany.com:3000/",
      "request_path": "/v1/test-api",
      "id": "13664E93-3A58-429B-818B-1204934E116E",
      "created_at": 1459539371000,
      "preserve_host": true,
      "name": "test-api",
      "request_host": ""
    }
  ],
  "total": 1
}


I'm trying to call the API as follows:

-H "X-Forwarded-For: 10.17.20.174" \
-H "Host: f1.api.mycompany.com" \
-H "X-Forwarded-Host: fb1.api.mycompany.com"


Kong is returning the following error:

HTTP/1.1 502 Bad Gateway
Date: Wed, 06 Apr 2016 13:52:01 GMT
Content-Type: text/plain; charset=UTF-8
Transfer-Encoding: chunked
Connection: close
Server: kong/0.7.0
An invalid response was received from the upstream server


I've done a package capture on the Kong server and these are the headers that are being sent from Kong:

GET /v1/test-api HTTP/1.0
X-Real-IP: 10.17.20.174
X-Forwarded-For: 10.17.20.174, 10.17.20.174
X-Forwarded-Proto: http
Host: lb-api.mycompany.com:3000
Connection: close
X-Forwarded-Host: fb1.api.mycompany.com
User-Agent: Paw/2.3.3 (Macintosh; OS X/10.10.5) GCDHTTPRequest 


I am expecting the Host header to be this:
"Host: f1.api.mycompany.com"


I've tried changing the APIs "preserve_host" to false and still get the same response.

Has anybody else seen this problem? Or is my understanding of how the the Host header is forward incorrect?

-Erik

Marco

unread,
Apr 20, 2016, 4:46:58 PM4/20/16
to Erik Azar, Kong
I cannot replicate this issue. Can you try again with Kong 0.8.0?


 Marco Palladino | CTO @ Mashape | mashape.com+1 (415) 361-3858

--
You received this message because you are subscribed to the Google Groups "Kong" group.
To unsubscribe from this group and stop receiving emails from it, send an email to konglayer+...@googlegroups.com.
To post to this group, send email to kong...@googlegroups.com.
Visit this group at https://groups.google.com/group/konglayer.
To view this discussion on the web visit https://groups.google.com/d/msgid/konglayer/1fe4c913-954a-42ed-9a2c-15be44414e90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages