首页 > 解决方案 > kubernetes,入口端口重定向问题

问题描述

问题:我的 java 应用程序在本地运行良好,但是当我将它部署在具有入口的 kubernetes 上时,出现端口转发问题..

在我的本地,以下 url 工作正常。

http://www.example.com:9080/app/eh
https://www.example.com:9443/app/eh
https://www.example.com/app/eh

在 kubernetes 环境中..

http://www.example2.com/app/eh (working)
https://www.example2.com/app/eh (expected)
https://www.example2.com:80/app/eh (real result)

当我访问https://www.example2.com/app/eh/xxxx页面时,它会将我带到https://www.example2.com:80/app/eh,而不是https://www。 example2.com/app/eh

kubectl get ing thcaas-eh
NAME        HOSTS   ADDRESS            PORTS     AGE
thcaas-eh   www.example2.com   158.87.63.26,...   80, 443   2d

kubectl describe ing thcaas-eh
Name:             thcaas-eh
Namespace:        thcaas-dev
Address:          158.87.63.26,158.87.63.27
Default backend:  default-http-backend:80 (100.127.50.199:8080)
TLS:
  tls.thcaas.icp1 terminates www.example2.com
Rules:
  Host                                              Path  Backends
  ----                                              ----  --------
  www.example2.com  
                                                    /app/eh   eh:9080 (<none>)
Annotations:
  ssl-redirect:         true
  tls-minimum-version:  1.2
Events:
  Type    Reason  Age               From                      Message
  ----    ------  ----              ----                      -------
  Normal  UPDATE  45m (x8 over 2d)  nginx-ingress-controller  Ingress thcaas-dev/thcaas-eh
  Normal  UPDATE  44m (x8 over 2d)  nginx-ingress-controller  Ingress thcaas-dev/thcaas-eh

我怎样才能让它在端口 443 上工作?带我到页面,https://www.example2.com/app/eh

标签: kubernetes

解决方案


更改为以下,有效。

from: Rules:
      Host                                              Path  Backends
      ----                                              ----  --------
      www.example2.com  
                                                        /app/eh   eh:9080 (<none>)

to: Rules:
          Host                                              Path  Backends
          ----                                              ----  --------
          www.example2.com  
                                                            /app/eh/   eh:9080 (<none>)

推荐阅读