<h2>Stack</h2>
<ul>
<li>Kubernetes (Digital Ocean)</li>
<li>Ingress Nginx Controller</li>
<li>React Frontend (static files)</li>
<li>NodeJS/Express Backend</li>
</ul>
<p>At certain point I need to load multiple images, more than a hundred, some are retrieved but many are not loaded. In the chrome console I get the following error:</p>
<pre><code>GET https://api.mydomain.com/images/products/F10014-soporte-caja-2.501.jpg net::ERR_HTTP2_SERVER_REFUSED_STREAM
</code></pre>
<p>This images are in a public express folder:</p>
<pre><code>let publicPath = path.join(__dirname, '/public')
console.log(`publicPath ${publicPath}`)
</code></pre>
<p>I looked at NodeJS and I couldn't find any errors. I also tried adding annotations in the <code>ingress-nginx</code> service:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
    kubernetes.digitalocean.com/load-balancer-id: &quot;e7f5dc8e-3723-11ec-8d3d-0242ac130003&quot;
    service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: &quot;true&quot;
    service.beta.kubernetes.io/do-loadbalancer-hostname: &quot;mydomain.com&quot;
  labels:
    helm.sh/chart: ingress-nginx-4.1.0
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/instance: ingress-nginx
    app.kubernetes.io/version: 1.0.0
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: controller
  name: ingress-nginx-controller
  namespace: ingress-nginx
spec:
  type: LoadBalancer
  externalTrafficPolicy: Local
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: http
    - name: https
      port: 443
      protocol: TCP
      targetPort: https
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/instance: ingress-nginx
    app.kubernetes.io/component: controller
</code></pre>
<p>My questions are:</p>
<ol>
<li>Is the problem in the <code>ingress-nginx</code> controller?</li>
<li>Can this be solved?</li>
<li>Should I change my solution and place the files in another place?</li>
</ol>
<p>Let me know if you need information.</p>

agusgambina
<p><strong>In short:</strong></p>
<blockquote>
<p>My questions are</p>
<ul>
<li>Is the problem in the ingress-nginx controller?</li>
</ul>
</blockquote>
<p><strong>Basically no</strong></p>
<blockquote>
<ul>
<li>Can this be solved?</li>
</ul>
</blockquote>
<p><strong>Yes</strong></p>
<blockquote>
<ul>
<li>Should I change my solution and place the files in another place?</li>
</ul>
</blockquote>
<p><strong>It depends :)</strong></p>
<h2>Explanation:</h2>
<p>First of all, you need to identify where the bug is coming from. You have received <code>ERR_HTTP2_SERVER_REFUSED_STREAM</code> from this request: <code>https://api.mydomain.com/images/products/F10014-soporte-caja-2.501.jpg</code>.  It looks like you tried to download too much data at once and got this error. How can you fix this error? First of all, you can try downloading data in batches, not all at once. Another solution is to configure your nginx server from which you download pictures. See the <a href="http://nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_concurrent_streams" rel="nofollow noreferrer">documentation</a>:</p>
<blockquote>
<p>Sets the maximum number of concurrent HTTP/2 streams in a connection.</p>
<p>Syntax:    http2_max_field_size size;
Default: http2_max_field_size 4k;
Context:   http, server</p>
</blockquote>
<p>You can here set up bigger value.</p>
<p>You can also set bigger value in the file <code>/etc/nginx/conf.d/custom_proxy_settings.conf</code> in the line</p>
<pre><code>http2_max_concurrent_streams 256;
</code></pre>
<p>The exact name of the file isn't important, it just have to end with .conf and be mounted inside /etc/nginx/conf.d.</p>
<p>Another solution could be disabling HTTP/2 and using HTTP/1.1 protocol, but it may be a security risk.</p>
<p>You have also asked:</p>
<blockquote>
<p>Should I change my solution and place the files in another place?</p>
</blockquote>
<p>You can, but it shouldn't be necessary.</p>
