I'm trying to configure nginx config in Docker but when I start "sudo docker-compose up -d" and try to connect to "http://localhost:8098/" I see: File not found.
and logs like:
docker-infrastructure_php-fpm_1 | 172.19.0.3 - 03/Mar/2022:21:35:35 +0000 "GET /index.php" 404
docker-infrastructure_nginx_1 | 172.19.0.1 - - [03/Mar/2022:21:35:35 +0000] "GET / HTTP/1.1" 404 27 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36" "-"`
There are my: nginx.conf
server {
listen 80;
server_name dgtips-backend-local;
root /home/sergey/PhpstormProjects/dgtips-backend/public;
index index.php;
location / {
try_files $uri /$uri /index.php?$query_string;
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME /home/sergey/PhpstormProjects/dgtips-backend$fastcgi_script_name;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
}
}
nginx.Dockerfile
FROM nginx
ADD docker/nginx/nginx.conf /etc/nginx/conf.d/default.conf
WORKDIR /home/sergey/PhpstormProjects/dgtips-backend/public
docker-compose.yml
version: "3.3"
services:
nginx:
build:
context: .
dockerfile: docker/nginx/nginx.Dockerfile
ports:
- 8098:80
volumes:
- ./:/home/sergey/PhpstormProjects/dgtips-backend
links:
- php-fpm
php-fpm:
build:
context: .
dockerfile: docker/php-fpm/fpm.Dockerfile
volumes:
- ./:/home/sergey/PhpstormProjects/dgtips-backend
And finally fpm.Dockerfile
FROM php:7.4-fpm
RUN apt-get update \
&& docker-php-ext-install pdo pdo_mysql
I'm completely sure that I have correct paths to my (local) project and to my index.php file