How to debug nginx 302 inside a kubernetes pod

9/26/2021

I am trying to build a magento app on kuberenetes. It worked in the past, but for some reason it is currently throwing a 302 error.

The app is using nginx as frontend, and phpfpm on the backend.

This is the code of the nginx configuration

This is what I see in nginx logs:

10.1.2.3 - - [26/Sep/2021:20:19:25 +0000] "GET /admin HTTP/1.1" 302 5 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" "10.244.43.0, 10.244.226.85"
10.1.2.3 - - [26/Sep/2021:20:19:26 +0000] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"

There are no errors in the backend logs (exception/system/debug). The access log in the backend looks like this:

10.1.2.3 -  26/Sep/2021:20:32:11 +0000 "GET /index.php" 302
10.1.2.3 -  26/Sep/2021:20:32:21 +0000 "GET /health_check.php" 200

I did strace on the phpfpm, and I saw activity, but I didn't see errors (though I might have missed it, strace log file is 10K lines, and I am not sure what to look for).

In the browser I see 502 error, bad gateway.

I tried to enable logging in nginx , but I can't stop the service, since it crashes the pod.

What can I do to debug and solve this 302 issue?

UPDATE

I used new relic and now I am able to see an error: upstream sent too big header while reading response header from upstream. I don't know why I was not able to see it in the pods directly. I am trying to fix using this

-- justadev
kubernetes
magento2
nginx

0 Answers