kong ring-balancer problem.

49 views
Skip to first unread message

Ma Yiwei

unread,
Nov 23, 2017, 1:12:36 AM11/23/17
to Kong
Hi:

I have some trouble when using kong as api gateway, anyone can help me?

It's my env:

kong‘s’ domain name: 'api.a.com', configured ring-balancer.

apis:
{
 
"hosts": [
   
"ml.a.com"
 
],
 
"upstream_send_timeout": 60000,
 
"retries": 5,
 
"http_if_terminated": true,
 
"https_only": false,
 
"name": "ml",
 
"uris": [
   
"/ml"
 
],
 
"id": "1d0ac719-0d3a-4c1d-837a-a31bc5371548",
 
"upstream_read_timeout": 60000,
 
"preserve_host": true,
 
"created_at": 1511407744000,
 
"upstream_connect_timeout": 60000,
 
"upstream_url": "http://ml.a.com",
 
"strip_uri": true
}


upstreams:
{
 
"created_at": 1511407613130,
 
"name": "ml.a.com",
 
"id": "9c18d009-9593-425f-9d8a-f761ee75b907",
 
"slots": 100,
 
"orderlist": [
   
10,
   
5,
   
2,
   
9,
   
4,
   
3,
   
1,
   
8,
   
7,
   
6
 
]
}


targets:
{
 
"total": 3,
 
"data": [
   
{
     
"upstream_id": "9c18d009-9593-425f-9d8a-f761ee75b907",
     
"created_at": 1511407654325,
     
"target": "192.168.0.1:80",
     
"id": "a6a325c2-0ff4-4629-a15e-28fca22edfb1",
     
"weight": 100
   
},
   
{
     
"upstream_id": "9c18d009-9593-425f-9d8a-f761ee75b907",
     
"created_at": 1511407658875,
     
"target": "192.168.0.2:80",
     
"id": "d46a5695-7d72-47dd-84fc-5c30a2d972fe",
     
"weight": 100
   
},
   
{
     
"upstream_id": "9c18d009-9593-425f-9d8a-f761ee75b907",
     
"created_at": 1511407662252,
     
"target": "192.168.0.3:80",
     
"id": "7dd304d5-714c-45a4-a5c6-2714ac3a410e",
     
"weight": 100
   
}
 
]
}




api server 192.168.0.1-3 runs on Nginx with multi vhosts.
'ml.a.com' is one of those vhosts, and no dns resovled(no dns server).

When request 'api.a.com/ml/style', the browser retuens 404.

I think the reason is missing 'HOST header', then I use command 'curl -H "Host:ml.a.com" http://api.a.com/ml/style' test and get the right answer.

I think if configured kong api parameters 'hosts' and 'preserve_host', kong will forward 'HOST header' to api server, but it seems didn't.

How can I solve this problem?

Thanks all of your help.
Reply all
Reply to author
Forward
0 new messages