Error message: NoHttpResponseException
The ingress-nginx-controller does not have keepalive HTTP headers.
Symptom
Applications in your cluster see NoHttpResponseException message. The application might stop running.
Cause
The keepalive_timeout setting is not configured in the Nginx ingress controller.
The keepalive_timeout sets the time during which a keep-alive client connection stays open on the server side. The default value is 60 seconds.
Resolving the problem
Complete these steps to add the keepalive_timeout setting. You need kubectl to run these commands. To install kubectl, see Installing the Kubernetes CLI (kubectl).
-
Edit the
ingress-nginx-controllerconfigmap.kubectl edit configmap nginx-ingress-controller -
Add the
server-snippetindatasection. Thekeepalive_timeoutvalue of88sis used here as an example. You can set the value to any integer in seconds.apiVersion: v1 data: disable-access-log: "true" keep-alive-requests: "10001" server-snippet: | keepalive_timeout 88s 88s; server-tokens: "false" -
Get the NGINX ingress controller pod name.
kubectl get pods | grep nginx -
Delete the
ingress-nginx-controllerpod and wait the pod to restart.kubectl delete pod <ingress-nginx-controller-pod-name> -
Verify that the keepalive parameter that you added in the
ingress-nginx-controllerconfigmap is also added to thenginx.conffile.kubectl exec -it <nginx-ingress-controller-pod> cat nginx.conf | grep keepaliveIf you do not see the parameter in the
nginx.conffile, restart your Nginx ingress controller pod by deleting it. -
Verify that the keepalive works. Run a service to test it. Following is an example.
curl -i -H "Connection: keep-alive" -H 'Host: example.com' http://10.11.6.166/bananaHere is a sample output:
HTTP/1.1 200 OK Date: Wed, 29 Jul 2020 06:23:10 GMT Content-Type: text/plain; charset=utf-8 Content-Length: 7 Connection: keep-alive Keep-Alive: timeout=88 X-App-Name: http-echo X-App-Version: 0.2.3 banana