Nginx upstream timed out (110: Connection timed out) while connecting to upstream when connecting to kubernetes ingress

12/22/2021

Getting connection timeout when doing nginx reverse proxy to kubernetes ingress. Not getting what is wrong here

Running minikube --driver=docker

2021/12/21 23:52:25 error 7#7: *6 upstream timed out (110: Connection timed out) while connecting to upstream, client: 10.227.224.11, server: , request: "GET / HTTP/1.1", upstream: "http://192.168.49.2:80/", host: "10.105.230.34:8089"

-bash-4.2$ kubectl get ingress
NAME              CLASS    HOSTS   ADDRESS        PORTS   AGE
ingress-service   <none>   *       192.168.49.2   80      12h
-bash-4.2$ 

But when I do a curl I get the response Also the curl works only when I do export no_proxy=$no_proxy,$(minikube ip)

bash-4.2$ curl http://192.168.49.2:80/
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link

nginx configuration:

server {

listen 80;


proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;


location / {
    proxy_pass http://192.168.49.2/;
    
    proxy_set_header Host $host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_buffering off;
    proxy_cache off;
    proxy_http_version 1.1;
    chunked_transfer_encoding off;
    proxy_request_buffering off;

}  

Ingress defn:

apiVersion: networking.k8s.io/v1
# UPDATE API
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: 'nginx'
    #nginx.ingress.kubernetes.io/use-regex: 'true'
    # ADD ANNOTATION
    #nginx.ingress.kubernetes.io/rewrite-target: /$1
    # UPDATE ANNOTATION 

Any pointers how to debug this.

Update: when i use port forwarding like below I am able to reach the application

sudo firewall-cmd --add-forward-port=port=8089:proto=tcp:toport=80:toaddr=192.168.49.2

-- Ajoy Das
kubernetes
kubernetes-ingress
nginx
reverse-proxy

0 Answers