F
F
First Name2018-10-25 20:35:12
Docker
First Name, 2018-10-25 20:35:12

How to properly set up nginx + fpm containers?

Hello.
Started learning docker.
I lift 2 containers.
1.nginx

docker run 
-d 
--name=nginx 
-v /home/user/docker/nginx/sites:/etc/nginx/conf.d/ 
-v /home/user/docker/app/:/var/www/html/
-p 80:80 
nginx

/home/user/docker/nginx/sites/default.conf

server {
listen 80;
server_name localhost;
root /var/www/html/index.php;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 172.17.0.2:9000;
}
}
/home/user/docker/app/index.php

<?php var_dump('test');

Everything is created and processed.
2. php-fpm
docker run
  -d
  --name=php
  -v /home/user/docker/nginx/app/:/var/www/html/
  -p 9000:9000
  php:7-fpm

/home/user/docker/nginx/app/index.php

<?php var_dump('test');

Everything is created and works.
Containers lie in the same network, they see each other.
BUT, when I access the site, it gives a white page with a 200 response code.
docker logs php

[25-Oct-2018 17:32:40] NOTICE: fpm is running, pid 1
[25-Oct-2018 17:32:40] NOTICE: ready to handle connections
172.17.0.3 - 25/Oct/2018:17:32:43 +0000 "- " 200
172.17.0.3 - 25/Oct/2018:17:32:43 +0000 "- " 200
docker logs nginx

172.17.0.1 - - [25/Oct/2018:17:32:43 +0000] "GET / HTTP/1.1" 200 5 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/70.0.3538.67 Chrome/70.0.3538.67 Safari/537.36" "-"
172.17.0.1 - - [25/Oct/2018:17:32:43 +0000] "GET /favicon.ico HTTP/1.1" 200 5 "127.0.0.1" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/70.0.3538.67 Chrome/70.0.3538.67 Safari/537.36" "-"

The question itself is why the wardump is not shown?
Thank you in advance for the answers :)
PS Do not throw slippers, I'm just starting to study

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tyranron, 2018-10-25
@maxxtweek

The Nginx config is missing the SCRIPT_FILENAMEFast-CGI parameter. You need to add the following:

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question