【问题标题】:Kong behind nginx reverse proxynginx反向代理背后的Kong
【发布时间】:2019-10-24 11:42:17
【问题描述】:

我使用 Kong 作为我的 API 网关,在 Docker 容器中运行。通过从 docker host 执行以下命令,我得到了正确的答案。

root@prod-s-swarm01:~# curl -i -X GET --url http://prod-s-swarm:8000 --header 'Host: example.com' --header 'apikey: auth-key-maks'

HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Date: Thu, 24 Oct 2019 11:16:10 GMT
Server: Apache/2.4.7 (Ubuntu)
Vary: Accept-Encoding
X-RateLimit-Remaining-hour: 4
X-RateLimit-Limit-second: 2
X-RateLimit-Remaining-second: 1
X-RateLimit-Limit-hour: 5
X-Kong-Upstream-Latency: 25
X-Kong-Proxy-Latency: 139
Via: kong/1.3.0

<!DOCTYPE html>
<html lang="ru">
<head>
.......

但是,通过我的 nginx 代理的这个请求返回不正确的答案:

root@prod-s-swarm01:~# curl -i -X GET --url https://kong.myserver.com --header 'Host: example.com' --header 'apikey: auth-key-maks'
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Oct 2019 11:14:33 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 97
Connection: keep-alive
X-Powered-By: Express
ETag: W/"61-Mn0BCF+92vC7dF087oyDAFsiE"

{"Status":"ERROR","Error":"Bad authorize","ErrorDesc":"Не верная авторизация"}

我的 nginx 代理配置:

server {

listen  443 ssl;
server_name kong.myserver.com;
ssl_certificate   /etc/letsencrypt/live/appgw/fullchain.pem;
ssl_certificate_key   /etc/letsencrypt/live/appgw/privkey.pem;

location / {
     proxy_pass      http://prod-s-swarm:8000;
     proxy_set_header   Host    $host;
}
}

我尝试使用 $http_host - 这也不起作用。

【问题讨论】:

  • 当然!另一个主机落在 nginx 上的 default_server 中。或者在 server_name 中必须在 kong api 中写入所有域。

标签: nginx kong


【解决方案1】:

另一个主机落在 nginx 上的 default_server 中。或者在 server_name 中必须在 kong api 中写入所有域。

【讨论】:

    猜你喜欢
    • 2019-03-14
    • 2021-04-01
    • 1970-01-01
    • 2017-08-14
    • 2022-06-23
    • 1970-01-01
    • 2012-02-04
    • 2019-08-31
    • 1970-01-01
    相关资源
    最近更新 更多