Istio gateway redirects to HTML nginx image doesn't work

I had Istio 1.3.3 gateway and helloworld gateway toward my application service.

Istio Gateway

apiVersion: v1
kind: Service
metadata:
  labels:
    app: istio-ingressgateway
    chart: gateways-1.0.0
    heritage: Tiller
    istio: ingressgateway
    release: RELEASE-NAME
  name: istio-ingressgateway
  namespace: istio-system
spec:
  externalTrafficPolicy: Cluster
  ports:
  - name: http2
    nodePort: 31380
    port: 80
    protocol: TCP
    targetPort: 80
  - name: https
    nodePort: 31390
    port: 443
    protocol: TCP
    targetPort: 443
  - name: tcp
    nodePort: 31400
    port: 31400
    protocol: TCP
    targetPort: 31400
  - name: tcp-pilot-grpc-tls
    nodePort: 32565
    port: 15011
    protocol: TCP
    targetPort: 15011
  - name: tcp-citadel-grpc-tls
    nodePort: 32352
    port: 8060
    protocol: TCP
    targetPort: 8060
  - name: http2-helloworld
    nodePort: 31750
    port: 15033
    protocol: TCP
    targetPort: 15033
  selector:
    app: istio-ingressgateway
    istio: ingressgateway
  type: LoadBalancer

HelloWorld Gateway

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: helloworld-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 15033
      name: http2-helloworld
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: helloworld
spec:
  hosts:
  - "*"
  gateways:
  - helloworld-gateway
  http:
  - match:
    - port: 15033
    route:
    - destination:
        host: helloworld
        port:
          number: 5000

HelloWorld.yaml

apiVersion: v1
kind: Service
metadata:
  name: helloworld
  labels:
    app: helloworld
spec:
  ports:
  - port: 5000
    name: http
  selector:
    app: helloworld
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: helloworld-v1
  labels:
    version: v1
spec:
  replicas: 2
  selector:
    matchLabels:
      app: helloworld
      version: v1
  template:
    metadata:
      labels:
        app: helloworld
        version: v1
    spec:
      containers:

      - name: helloworld
        image: karthequian/helloworld:latest
        resources:
          requests:
            cpu: "100m"
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80

When I tried to access the application from Istio gateway using localhost:15033, working with different port and docker images are working fine, but this docker image that used nginx doesn’t work well.

I got an error when access to localhost:15033

upstream connect error or disconnect/reset before headers. reset reason: connection termination

Your service “helloworld” needs a “targetPort” or your Deployment needs a port name “http” to match.

1 Like

Thanks you so much for your solution. It solved. :slight_smile: