title: Why does attempting to connect to my ingress show connection refused?
body: <p>I'm running kubernetes 1-21-0 on Centos7. I've set up a keycloak service to test my ingress controller and am able to access the keycloak on the host url with the keycloak port like <code>myurl.com:30872</code>. These are my running services:</p>
  <pre><code>NAMESPACE       NAME                                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
  default         keycloak                             NodePort    10.96.11.164    &lt;none&gt;        8080:30872/TCP               21h
  default         kubernetes                           ClusterIP   10.96.0.1       &lt;none&gt;        443/TCP                      11d
  ingress-nginx   ingress-nginx-controller             NodePort    10.102.201.24   &lt;none&gt;        80:31110/TCP,443:30566/TCP   9m45s
  ingress-nginx   ingress-nginx-controller-admission   ClusterIP   10.107.90.207   &lt;none&gt;        80/TCP,443/TCP               9m45s
  kube-system     kube-dns                             ClusterIP   10.96.0.10      &lt;none&gt;        53/UDP,53/TCP,9153/TCP       11d
  </code></pre>
  <p>I've deployed the following <a href="https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.44.0/deploy/static/provider/baremetal/deploy.yaml" rel="nofollow noreferrer">nginx ingress controller</a>.</p>
  <p>And added an HTTP webhook to the service:</p>
  <pre><code># Source: ingress-nginx/templates/controller-service-webhook.yaml
  apiVersion: v1
  kind: Service
  metadata:
    labels:
      helm.sh/chart: ingress-nginx-3.23.0
      app.kubernetes.io/name: ingress-nginx
      app.kubernetes.io/instance: ingress-nginx
      app.kubernetes.io/version: 0.44.0
      app.kubernetes.io/managed-by: Helm
      app.kubernetes.io/component: controller
    name: ingress-nginx-controller-admission
    namespace: ingress-nginx
  spec:
    type: ClusterIP
    ports:
      - name: http-webhook
        port: 80
        targetPort: webhook
      - name: https-webhook
        port: 443
        targetPort: webhook
    selector:
      app.kubernetes.io/name: ingress-nginx
      app.kubernetes.io/instance: ingress-nginx
      app.kubernetes.io/component: controller
  </code></pre>
  <p>With this ingress:</p>
  <pre><code>apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: keycloak
    annotations:
      kubernetes.io/ingress.class: nginx
      nginx.ingress.kubernetes.io/rewrite-target: /
  spec:
    rules:
      - http:
          paths:
          - path: /keycloak
            pathType: Prefix
            backend:
              service:
                name: keycloak
                port: 
                  number: 8080
  </code></pre>
  <p>Now when I attempt to connect to the keycloak service through the ingress I go to <code>myurl.com/keycloak</code> but it's unable to connect and trying to curl it from within my control node shows connection refused:</p>
  <pre><code># curl -I http://127.0.0.1/keycloak
  curl: (7) Failed connect to 127.0.0.1:80; Connection refused
  </code></pre>
  <p>Can someone see what I'm missing?</p>
  <p><strong>Edit:</strong></p>
  <p>I realized the ingress controller actually works, but I need to specify its port also to reach it like this:</p>
  <pre><code>curl -I http://127.0.0.1:31110/keycloak
  </code></pre>
  <p>Which I'd like to avoid.</p>