Skip to content

How to use nginx /dbg

This document (000020126) is provided subject to the disclaimer at the end of this document.

Situation

What is the /dbg command

/dbg is a program included in the ingress-nginx container image that can be used to show information about the nginx environment and the resulting nginx configuration, which can be helpful when debugging ingress issues in Kubernetes.

Requirements

  • A Kubernetes cluster that has ingress enabled with ingress-nginx as the ingress controller
  • A cluster with Linux nodes, nginx will not run on Windows
  • kubectl configured

Using /dbg

This command needs to be run from inside one of the ingress-nginx pods, so first determine the pod to run it in.

> kubectl get pods -n ingress-nginx
NAME                                    READY   STATUS    RESTARTS   AGE
default-http-backend-67cf578fc4-54jlz   1/1     Running   0          5d
nginx-ingress-controller-56nss          1/1     Running   0          5d
nginx-ingress-controller-hscfg          1/1     Running   0          4d21h
nginx-ingress-controller-n4p22          1/1     Running   0          5d
> export NGINX_POD=nginx-ingress-controller-n4p22

If you are diagnosing specific connection issues, you can determine which controller is receiving the traffic by looking through the logs of each.

Viewing ingress-controller status

/dbg general will show the count of running controllers.

> kubectl exec -n ingress-nginx $NGINX_POD /dbg  general
{
  "controllerPodsCount": 3
}

Viewing backend configuration

/dbg backends list will list the discovered backends:

```

kubectl exec -n ingress-nginx $NGINX_POD /dbg backends list cattle-system-rancher-80 upstream-default-backend ```

/dbg backends get will show the configuration for the named backend:

 > kubectl exec -n ingress-nginx $NGINX_POD /dbg backends get cattle-system-rancher-80

Viewing ingress certificate data

/dbg certs will dump the x509 cert and key for a certificate that nginx has discovered from k8s secrets for the given hostname:

> kubectl exec -n ingress-nginx $NGINX_POD /dbg certs get <fqdn>

Viewing dynamically generated nginx configuration

/dbg conf will dump the dynamically generated nginx configuration. To view the configuration for a specific ingress hostname, you could run /dbg conf and then grep for the server_name:

> kubectl exec -n ingress-nginx $NGINX_POD /dbg conf | grep "server_name example.com" -B2 -A20

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.