【问题标题】:Docker Kong admin API is unreachableDocker Kong 管理 API 无法访问
【发布时间】:2018-12-25 06:32:34
【问题描述】:

我已将the Docker Kong image 升级到版本 0.14.0,它停止响应来自容器外部的连接:

$ curl 127.0.0.1:8001 --trace-ascii dump.txt

== Info: Rebuilt URL to: 127.0.0.1:8001/
== Info:   Trying 127.0.0.1...
== Info: Connected to 127.0.0.1 (127.0.0.1) port 8001 (#0)
=> Send header, 78 bytes (0x4e)
0000: GET / HTTP/1.1
0010: Host: 127.0.0.1:8001
0026: User-Agent: curl/7.47.0
003f: Accept: */*
004c: 
== Info: Recv failure: Connection reset by peer
== Info: Closing connection 0

端口映射是

0.0.0.0:8000-8001->8000-8001/tcp, 0.0.0.0:8443-8444->8443-8444/tcp

尝试从容器内部连接时一切正常:

/ # curl 127.0.0.1:8001
{"plugins":{"enabled_in_cluster":[], ...

8000 端口可从容器外部和内部使用。那会是什么?

【问题讨论】:

    标签: docker kong


    【解决方案1】:

    我也遇到了同样的问题。原因是kong admin配置默认设置为loopback地址。但是我没有修改配置文件。由于 Kong Docker Image 提供了一个环境变量来暴露管理端口。

    KONG_ADMIN_LISTEN="0.0.0.0:8001, 0.0.0.0:8444 ssl"
    

    这会将管理端口绑定到主机端口

    【讨论】:

      【解决方案2】:

      问题在于管理服务器绑定到 /usr/local/kong/nginx-kong.conf 中的 localhost

      server {
          server_name kong_admin;
          listen 127.0.0.1:8001;
          listen 127.0.0.1:8444 ssl;
      ...
      

      我已将以下代码添加到我的自定义入口点中,该入口点在启动 nginx 之前删除了此绑定:

      echo "Remove the admin API localhost binding..."
      sed -i "s|^\s*listen 127.0.0.1:8001;|listen 0.0.0.0:8001;|g" /usr/local/kong/nginx-kong.conf && \
      sed -i "s|^\s*listen 127.0.0.1:8444 ssl;|listen 0.0.0.0:8444 ssl;|g" /usr/local/kong/nginx-kong.conf
      
      echo "Starting nginx $PREFIX..."
      
      exec /usr/local/openresty/nginx/sbin/nginx \
        -p $PREFIX \
        -c nginx.conf
      

      当然,管理端口必须在生产中以其他方式关闭。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-07-30
        • 2019-12-12
        • 2018-10-25
        • 2021-09-24
        • 2022-11-11
        • 2021-08-09
        • 2021-09-12
        • 1970-01-01
        相关资源
        最近更新 更多