Host nginx accesses php error in docker container

the native Nginx, I used then built a PHP7 environment on the machine with Docker. Php-fpm was started in Docker and the port was mapped. The host 9200 was mapped to 9000 in the container and added a code directory to the data volume. However, an error was reported in the php in the docker with native nginx access. The port of nginx access php-fpm uses the mapped port, fastcgi_pass 127.0.0.1 fastcgi_pass 9200;

The error log of

nginx is as follows:

2018-06-06 20:36:52 [error] 81417 upstream prematurely closed connection while reading response header from upstream, client: sharp0: * 500 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: wq.cn, request: "GET / / test.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9200"

can connect to it, which probably means that the connection is closed prematurely when the response header is read from the upstream. Look up the solution on the Internet, did not find, I do not know if there is a god can help solve it, thank you very much!

Mar.17,2021

cannot use 127.0.0.1 . Php is already another computer for you, not the local computer. You need to check the ip of the container in docker.
another solution is that nginx is also made into a container, and then associate the php container with the nginx container, so that you can set the alias of the php container, and you do not need to change the ip every time you start the container

.
Menu