<p>I have a local website.
The website was created by a docker-compose and it is listening on a localhost port 3000.</p>
<p>When I try:</p>
<pre><code>curl 127.0.0.1:3000
</code></pre>
<p>I can see the response.</p>
<p>What I did:</p>
<p>From my domain provider I edited the DNS to point to my server, then I changed nginx-ingress:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: virtual-host-ingress
  namespace: ingress-basic
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
    cert-manager.io/cluster-issuer: &quot;letsencrypt-pp&quot;
spec:
  tls:
  - hosts:
    - nextformulainvesting.com
    secretName: ***
  rules:
  - host: &quot;nextformulainvesting.com&quot;
    http:
      paths:
      - pathType: Prefix
        path: &quot;/&quot;
        backend:
          service:
            name: e-frontend-saleor
            port:
              number: 80
</code></pre>
<p>and I created the service:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: e-frontend-saleor
spec:
  ports:
    - protocol: TCP
      port: 80
      targetPort: 3000
</code></pre>
<p>But with the service or without the service I receive the error <code>503 Service Temporarily Unavailable</code>.</p>
<p>How can I use nginx-ingress to point to my local TCP service?</p>

<p>To clarify the issue I am posting a community wiki answer.</p>
<p>The answer that helped to resolve this issue is available at <a href="https://stackoverflow.com/questions/57764237/kubernetes-ingress-to-external-service">this link</a>.  Based on that - the clue of the case is to create manually a Service and an Endpoint objects for external server.</p>
<p>After that one can create an Ingress object that will point to Service  <code>external-ip</code>  with adequate port .</p>
<p>Here are the examples of objects provided in <a href="https://stackoverflow.com/questions/57764237/kubernetes-ingress-to-external-service">similar question</a>.</p>
<ul>
<li>Service and an Endpoint objects:</li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: external-ip
spec:
  ports:
  - name: app
    port: 80
    protocol: TCP
    targetPort: 5678
  clusterIP: None
  type: ClusterIP
---
apiVersion: v1
kind: Endpoints
metadata:
  name: external-ip
subsets:
- addresses:
  - ip: 10.0.40.1
  ports:
  - name: app
    port: 5678
    protocol: TCP

</code></pre>
<ul>
<li>Ingress object:</li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: external-service
spec:
  rules:
  - host: service.example.com
    http:
      paths:
      - backend:
          serviceName: external-ip
          servicePort: 80
        path: /
</code></pre>
<p>See also <a href="https://github.com/kubernetes/kubernetes/issues/8631#issuecomment-104404768" rel="nofollow noreferrer">this reference</a>.</p>
