【问题标题】:Kubectl proxy behind NGINX: invalid upgrade responseNGINX 背后的 Kubectl 代理:无效的升级响应
【发布时间】:2021-05-28 05:14:06
【问题描述】:

我正在尝试将本地 Kubernates 集群添加到我的 GitLab 组以进行 CI/CD 部署。我已经开始运行以下命令:

kubectl proxy --address 0.0.0.0 --accept-hosts '.*'

我已经测试过它在同一网络中的另一台机器上执行curl http://localhost:8001/api 和运行curl http://192.168.1.2:8001/api。代理在我的本地网络中可用。

下一步是在 kubernates.example.com 后面的 Internet 上提供代理。为此,我将 NGINX 配置如下:

server {
    server_name kubernates.example.com;
    listen 443 ssl;
    listen 80;

    include ssl_standart_conf;

    location / {
        proxy_pass http://192.168.1.2:8001/;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

执行curl https://kubernates.example.com/api返回如下错误:

invalid upgrade response: status code 200

Kubernates 代理日志

E0225 22:33:50.944018 1642369 upgradeaware.go:312] Proxy upgrade error: invalid upgrade response: status code 200
E0225 22:33:50.944060 1642369 proxy_server.go:144] Error while proxying request: invalid upgrade response: status code 200

【问题讨论】:

    标签: nginx kubernetes proxy kubectl nginx-reverse-proxy


    【解决方案1】:

    好的,我已经设法解决了这个问题。下面的nginx配置做了个技巧

    server {
        server_name kubernates.example.com;
        listen 443 ssl;
        listen 80;
    
        include ssl_standart_conf;
    
        location / {
            proxy_pass http://192.168.1.2:8001/;
            proxy_set_header Host $host;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-05-19
      • 2016-07-16
      • 1970-01-01
      • 2011-08-29
      • 1970-01-01
      • 2015-10-20
      • 2021-03-13
      • 2017-08-14
      • 2022-06-23
      相关资源
      最近更新 更多