<p>I have several PHP applications which I am trying to configure inside K8s.
Currently I have issue with one custom service - it is using own server (listening 8800 port) and nginx server which is redirecting traffic from 80/443 (we can use 80 this time to simplify example) to 8800.</p>
<p>Here is part of nginx conf:</p>
<pre><code>location / {
  add_header Access-Control-Allow-Origin $http_origin always;
  add_header Access-Control-Allow-Credentials true always;
  proxy_set_header        X-Real-IP $remote_addr;
  proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header        X-Forwarded-Proto $scheme;
  proxy_cache             off;

  proxy_pass              http://localhost:8800;

  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection &quot;upgrade&quot;;
  proxy_redirect          off;
  proxy_hide_header Access-Control-Allow-Origin;
  proxy_hide_header Access-Control-Allow-Credentials;
}
</code></pre>
<p>I already configured deployments + services for my pods but I am new in NGINX Ingres.
Currently I am working with this ingress but I am getting 500 error (502 Bad Gateway) and looks like my traffic does not reach my service.</p>
<pre><code>---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-[service]
  annotations:       
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
  - host: [my domain name]
    http:
      paths:
      - path: /api/
        pathType: Prefix
        backend:
          service:
            name: [service]
            port:
              number: 8800
  ingressClassName: nginx
</code></pre>
<p>Did I convert nginx to ingres config correctly?</p>
<p>UPDATE: deployment + service (my last variant)</p>
<pre><code>---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: some-service
spec:
  replicas: 1
  ...
    spec:
      containers:
      - name: [some-name]
        image: [image]
        imagePullPolicy: Always
        env:
        ...
        ports:
          - containerPort: 8800
            name: some-web-svc

---
apiVersion: v1
kind: Service
metadata:
  name: some-service
spec:
  type: ClusterIP
  ports:
  - name: some-service-port
    protocol: TCP
    port: 8800
    targetPort: some-web-svc
    # - name: tcp
    #   port: 8800
    #   targetPort: 8800
  selector:
    app: some-service
</code></pre>

prosto.vint
<ul>
<li>Run the command below to check whether your service is mapped to your
podIP:port properly.</li>
<li>If the ENDPOINTS column in the output of the command below does not show podIP:port, then your service is most likely misconfigured - Label in the deployment is not matching with the selector in the service</li>
<li>Fix the selectors to solve the issue</li>
</ul>
<p>--</p>
<pre><code>kubectl get ep -n &lt;namespace&gt;
</code></pre>
