<p>I'm building an API than enable users to stream (push) large content through HTTP and I would like to be able to process the request from a nodejs express server <strong>while the client is still pushing</strong>.</p>
<p><em>client.js</em></p>
<pre class="lang-js prettyprint-override"><code>const request = require('request');
someReadableStream.pipe(request({
    method: &quot;POST&quot;,
    uri: `${process.env.SERVER_URL || &quot;https://streaming.service.com/&quot;}/`,
    headers: {
      'Authorization': `Bearer ${API_TOKEN}`,
    },
}));
</code></pre>
<p><em>server.js</em></p>
<pre class="lang-js prettyprint-override"><code>const express = require('express');
const app = express();
app.post('/', function rootPostHandler(req, res) {
  console.log('request received');
  const tickInterval = setInterval(() =&gt; console.log('tick'), 1000);
  req.on('data', (chunk) =&gt; console.log('data received'));
  req.on('end', () =&gt; {
    console.log('request end received');
    clearInterval(tickInterval);
    res.end('done')
  });
});

app.listen(process.env.PORT);
</code></pre>
<p>Everything works as expected on my development server: server receives data and can start processing it while client is still pushing (see per-second <code>tick</code>s in output below).</p>
<p><em>dev server output:</em></p>
<pre><code>request received
data received
data received
data received
tick
data received
data received
data received
tick
data received
data received
data received
tick
data received
data received
request end received
</code></pre>
<p>Now, when we deploy the same server code to our kubernetes cluster, initial experiments suggest that <a href="https://kubernetes.github.io/ingress-nginx/" rel="nofollow noreferrer">Nginx Ingress</a> (or some other K8s component) wait the request to be completed before sending it to the underlying HTTP service (no <code>tick</code> in output below).</p>
<p><em>server pod logs</em></p>
<pre><code>request received
data received
data received
data received
data received
data received
data received
data received
data received
data received
data received
data received
request end received
</code></pre>
<p><em>kubernetes config</em></p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
  labels:
    tier: ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    cert-manager.io/cluster-issuer: &quot;issuer&quot;
    nginx.ingress.kubernetes.io/proxy-body-size: 30720m
    nginx.ingress.kubernetes.io/proxy-connect-timeout: &quot;180&quot;
    nginx.ingress.kubernetes.io/proxy-read-timeout: &quot;180&quot;
    nginx.ingress.kubernetes.io/proxy-send-timeout: &quot;180&quot;
    nginx.ingress.kubernetes.io/enable-cors: &quot;true&quot;
    nginx.ingress.kubernetes.io/cors-allow-origin: &quot;*&quot;
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_pass_request_headers      on;
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - streaming.service.com
      secretName: streaming-tls
  rules:
    - host: streaming.service.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: streaming
                port:
                  number: 80
---
apiVersion: v1
kind: Service
metadata:
  name: streaming
  labels:
    app: streaming
spec:
  type: ClusterIP
  clusterIP: None
  sessionAffinity: ClientIP
  ports:
    - port: 80
  selector:
    app: streaming
</code></pre>
<p><strong>Question:</strong> Is here a way to tell nginx-ingress to forward bytes to underlying HTTP service as they arrive, through <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/" rel="nofollow noreferrer">annotations</a> or <a href="https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-snippets/" rel="nofollow noreferrer">snippets</a> for example ?</p>

<p><strong>Answering to my own question</strong> since it may help others</p>
<p>All you have to do is to add <code>nginx.ingress.kubernetes.io/proxy-request-buffering: &quot;off&quot;</code> annotation</p>
<p><em>New Ingress configuration</em></p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-stream
  labels:
    name: ingress-stream
    tier: ingress
  annotations:
    nginx.ingress.kubernetes.io/proxy-request-buffering: &quot;off&quot;  # here
spec:
  ingressClassName: nginx
  rules:
    - host: streaming.service.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: streaming
                port:
                  number: 80
</code></pre>
