1

I have a Laravel project that needs PHP 7.1 but on the server, we use 7.2. We have separate nginx config files for each project and they all work fine.

I've decided to go laradock and serve PHP 7.1 for the project. Starts up like a charm out of the box, however... After I've built the docker images I get the following:

0 ✓ server /var/www/html/myproject.com/laradock $ docker-compose ps
           Name                          Command              State          Ports        
------------------------------------------------------------------------------------------
laradock_docker-in-docker_1   dockerd-entrypoint.sh           Up      2375/tcp, 2376/tcp  
laradock_php-fpm_1            docker-php-entrypoint php-fpm   Up      9000/tcp            
laradock_workspace_1          /sbin/my_init                   Up      0.0.0.0:2222->22/tcp

In my NginX config, I'm trying to rewrite the root location like:

fastcgi_pass 127.0.0.1:9000;

No luck, I get 2019/11/06 14:06:42 [error] 1287#1287: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 84.X.XX.207, server: myproject.com, request: "GET /item/show/24401 HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "myproject.com", referrer: "https://myproject.com/"

Any ideas what is happening? :(

UPDATE

I've tried again, this time with the IP address of the php-fpm docker image that I've got by executing nspect 9d15baXXXXXX | grep IPAddress

Now, the log looks like this:

2019/11/06 14:58:49 [error] 12391#12391: *2 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 84.2.XX.XXX, server: myproject.com, request: "GET /item/show/2350 HTTP/2.0", upstream: "fastcgi://192.168.XX.X:9000", host: "myproject.com", referrer: "https://myproject.com/"

Still a bit confused what is happening.

UPDATE #2

OK, I've figured out some stuff.

Firstly, the IP address of the PHP-FPM docker is good in the fastcgi_pass BUT, I MUST rewrite fastcgi_param SCRIPT_FILENAME. Normally I have $document_root$fastcgi_script_name there, but that is not the same as inside the docker. I had to modify it to /var/www/public$fastcgi_script_name. But now, this is getting more complicated, since now all I get is a browser error 500 message, so no logs in my NginX.

How should I debug this?

Bert
  • 984
  • 1
  • 11
  • 29

0 Answers0