Hi
I have simply been trying to get 2 docker containers working together without much success. The 2 containers are nginx and php. I can get nginx working and displaying the default html file or a 403 error when trying to access a php file.
I am using docker composer, i followed a guide to a tee and re read many times but cannot get it going. i bet I am missing something really simple and obvious.
docker-compose.yml
web:
image: nginx:latest
ports:
- "8181:80"
volumes:
- ./site.conf:/etc/nginx/conf.d/site.conf
- /var/www/dev:/usr/share/nginx/html
links:
- php
php:
image: php:7-fpm
volumes:
- /var/www/dev:/usr/share/nginx/html
ports:
- "9000:9000"
site.conf
server {
index index.php index.html;
server_name 0.0.0.0:80;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
output when accessing index.php
Starting carl_php_1
Starting carl_web_1
Attaching to carl_php_1, carl_web_1
php_1 | [16-Jun-2019 11:56:16] NOTICE: fpm is running, pid 1
php_1 | [16-Jun-2019 11:56:16] NOTICE: ready to handle connections
web_1 | 10.0.0.50 - - [16/Jun/2019:11:56:20 +0000] "GET / HTTP/1.1" 403 555 "-" "Mozilla/5.0 (Windows
NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36" "-"
web_1 | 2019/06/16 11:56:20 [error] 6#6: *1 directory index of "/usr/share/nginx/html/" is forbidden, client:
10.0.0.50, server: localhost, request: "GET / HTTP/1.1", host: "10.0.0.187:8181"
I have chmod’d 777 all the files in /var/www/dev as a test to see if its permission errors. I also have a test.php which it will download whne accessing and has the correct contents.
Any pointers plllleeeeeaaaase?!?