docker nginx 404 not found

Viewed 104

Why I get this error when visit localhost:8080! Any suggestion to solve this issue is welcome because I spend many time for it and I changed PHP docker file and nginx file many times, similar version with laravel framework is ok for me.

*1 open() "/var/www/html/myapp404" failed (2: No such file or directory)

Note that myapp folder contains index.php and other files but it is not a Laravel framework. My docker compose:

version: '3.8'
services:
    nginx:
        build:
            context: .
            dockerfile: nginx.dockerfile
        ports:
            - 8080:80
        depends_on:
            - php
            - mysql
    php:
        build:
            context: .
            dockerfile: php.dockerfile
        container_name: php
        volumes:
        - ${PWD}/myapp:/var/www/html/myapp
        working_dir: /var/www/html/myapp
        ports:
        - "9000:9000"
    mysql:
        image: yobasystems/alpine-mariadb
       
        ports:
        - "3308:3308"
        volumes:
        - ./mariadb/data:/var/lib/mysql
        - ./mariadb/my.conf:/etc/my.cnf
        environment:
            MYSQL_ROOT_PASSWORD: "111"
            MYSQL_DATABASE: myapp
            MYSQL_USER: root
            MYSQL_PASSWORD: "111"
            restart: always

My default.conf => Nginx:

server {
 
  listen 80;
    index index.php index.html;
    server_name localhost;
    error_log /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/html/myapp;
    
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
  # pass the PHP scripts to FastCGI server listening on php:9000
  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;
  }
}

nginx:

FROM nginx:stable-alpine
ADD nginx/default.conf /etc/nginx/conf.d/default.conf

php :

FROM dwchiang/nginx-php-fpm:latest

Thanks.

0 Answers
Related