Home > Software engineering >  Docker - Nginx PHP-FPM - giving 502 error
Docker - Nginx PHP-FPM - giving 502 error

Time:06-24

I am running a POC to host index.php on Nginx using PHP-FPM FastCGI in docker container. I have a bare minimum configuration for Nginx but I am unable to make it work when I run curl -i http://localhost:8080, it gives the following similar errors in Nginx logs (note: I have only run the curl command once):

127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
127.0.0.1 - - [23/Jun/2022:19:24:29  0000] "GET /index.php HTTP/1.0" 502 497 "-" "curl/7.29.0" "-"
172.17.0.1 - - [23/Jun/2022:19:24:29  0000] "GET / HTTP/1.1" 502 497 "-" "curl/7.29.0" "-"
2022/06/23 19:30:05 [error] 12#12: *4085 open() "/usr/share/nginx/html/version" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /version?timeout=32s HTTP/1.1", host: "localhost:8080"

Dockerfile

FROM nginx:stable-alpine

WORKDIR /usr/share/nginx/html

RUN apk update && apk upgrade
RUN apk add openrc php php-fpm

COPY index.php /usr/share/nginx/html/

# this is near to the default config provided by Nginx
COPY default.conf /etc/nginx/conf.d/

# entrypoint script runs php-fpm first then nginx
COPY entrypoint.sh entrypoint.sh

# copying this as I have made modifications to enable logs of php-fpm
COPY php-fpm.conf /etc/php8/php-fpm.conf

CMD ["sh", "entrypoint.sh"]

entrypoint.sh

#!/usr/bin/env sh
set -e

php-fpm8 -D
nginx -g 'daemon off;'

nginx.conf

server {
    listen       80;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.php;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    location ~ \.php$ {
        proxy_pass   http://127.0.0.1;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

index.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PHP - Hello, World!</title>
</head>
<body>
        <h1><?php echo 'Hello, World!'; ?></h1>
</body>
</html>

I have tried to provide the give nginx user permissions to /usr/share/nginx/html using chown -R nginx:nginx /usr/share/nginx/html as well it didn't work.

Lastly, I am building and running the docker using below commands:

docker build -t my-php .
docker run -d -p 8080:80 --name my-php my-php

I know I am doing something very basic wrong but have been working on this but couldn't find the root cause and logs aren't helping either.

Note: Yes, I want to have nginx and php-fpm in the same image and for now I don't intend to use supervisor as I am looking for a solution to the current problem.

UPDATE 1:

As pointed out by @Daniele Rugginenti in comments, I had some misconfiguration in nginx due to which the request was looping

---

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
    }

---

After commenting the first part, when again trying to curl I am getting below in response:

HTTP/1.1 404 Not Found
Server: nginx/1.22.0
Date: Thu, 23 Jun 2022 21:10:23 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/8.0.20

File not found.

Container logs are below:

2022/06/23 21:10:23 [error] 13#13: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.17.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8080"
172.17.0.1 - - [23/Jun/2022:21:10:23  0000] "GET / HTTP/1.1" 404 27 "-" "curl/7.29.0" "-"

CodePudding user response:

The last error is normally related to

script filename

path error

Try with default configuration:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  • Related