<p>I have one api, which will run about 4 minutes. I have deployed it on kubernetes with ingress-nginx. All api work normally except the long-run api, it always return 504 Gateaway as below:
<a href="https://i.stack.imgur.com/zBS9z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zBS9z.png" alt="enter image description here" /></a></p>
<p>I have check in stackoverflow, and try some solution, none of it work for me.</p>
<p>any help is welcome.</p>
<p><a href="https://stackoverflow.com/questions/63945381/kubernetes-ingress-specific-app-504-gateway-time-out-with-60-seconds">Kubernetes Ingress (Specific APP) 504 Gateway Time-Out with 60 seconds</a></p>
<p>I have changed ingress config as below:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{  .Values.releaseName }}-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: 'true'
    nginx.ingress.kubernetes.io/affinity: cookie
    nginx.ingress.kubernetes.io/session-cookie-name: &quot;route&quot;
    nginx.ingress.kubernetes.io/session-cookie-expires: &quot;172800&quot;
    nginx.ingress.kubernetes.io/session-cookie-max-age: &quot;172800&quot;
    nginx.ingress.kubernetes.io/server-snippet: &quot;keepalive_timeout 3600s; grpc_read_timeout 3600s; grpc_send_timeout 3600s;client_body_timeout 3600s;&quot;
    nginx.ingress.kubernetes.io/proxy-connect-timeout: &quot;3601&quot;
    nginx.ingress.kubernetes.io/proxy-send-timeout: &quot;3601&quot;
    nginx.ingress.kubernetes.io/proxy-read-timeout: &quot;3601&quot;
    # nginx.org/proxy-connect-timeout: 3600s
    # nginx.org/proxy-read-timeout: 3600s
    # nginx.org/proxy-send-timeout: 3600s
    nginx.ingress.kubernetes.io/proxy-body-size: &quot;100M&quot;
    nginx.ingress.kubernetes.io/proxy-next-upstream: &quot;error non_idempotent  http_502 http_503 http_504&quot;
    nginx.ingress.kubernetes.io/retry-non-idempotent: &quot;true&quot;
    nginx.ingress.kubernetes.io/proxy-next-upstream-timeout: &quot;5&quot;
    nginx.ingress.kubernetes.io/proxy-next-upstream-tries: &quot;1&quot;
    # nginx.ingress.kubernetes.io/configuration-snippet: |-
    #   location  /HouseKeeping/Health/Healthz {
    #       deny all;
    #       return 403;
    #     }
    #   location  /InternalApi/ {
    #     deny all;
    #     return 403;
    #   }
    nginx.ingress.kubernetes.io/server-snippets: |
      http {
        client_max_body_size 100m;
      }
      location / {
        proxy_set_header Upgrade $http_upgrade;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Host  $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Port  $server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header Connection $http_connection;
        proxy_cache_bypass $http_upgrade;
        proxy-connect-timeout: 3602;
        proxy-read-timeout: 3602;
        proxy-send-timeout: 3602;
      }
      
spec:
  rules:
    - host: {{  .Values.apiDomain }}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: {{  .Values.releaseName }}-web-clusterip-srv
                port:
                  number: 80
</code></pre>
<p>I also change the configMap for ingress-nginx-controller to add below config:</p>
<pre><code>apiVersion: v1
data:
  allow-snippet-annotations: &quot;true&quot;
  proxy-connect-timeout: &quot;300&quot;
  proxy-read-timeout: &quot;300&quot;
  proxy-send-timeout: &quot;300&quot;
kind: ConfigMap
</code></pre>
<p>I also used command to get ingress-nginx's conf, it seems okay</p>
<pre><code>kubectl -n ingress-nginx exec ingress-nginx-controller-6cc65c646d-ljmrm cat /etc/nginx/nginx.conf | tee nginx.test-ingress-export.conf
</code></pre>
<pre><code> # Custom headers to proxied server

 proxy_connect_timeout                   3601s;
 proxy_send_timeout                      3601s;
 proxy_read_timeout                      3601s;
</code></pre>
<p>it still timeout in 120 seconds.</p>

miemengniao
<p><strong>Typo</strong></p>
<p>Replace below (ingress config):</p>
<pre><code>nginx.ingress.kubernetes.io/proxy-next-upstream-timeout: &quot;5&quot;
nginx.ingress.kubernetes.io/proxy-next-upstream-tries: &quot;1&quot;
</code></pre>
<p>In place of (ingress config)</p>
<pre><code>nginx.ingress.kubernetes.io/proxy_next_upstream_timeout: &quot;5&quot;
nginx.ingress.kubernetes.io/proxy_next_upstream_tries: &quot;1&quot;
</code></pre>
<p><strong>Edit :</strong></p>
<p>Check this <a href="https://github.com/kubernetes/ingress-nginx/issues/2007#issuecomment-656662251" rel="nofollow noreferrer">comment</a> may help to resolve your issue.</p>
