1

following is my docker-compose.yml

version: "3.7"

services:
  php:
    build:
      context: .
    volumes:
      - ".:/app"
      - "~/.ssh:/root/.ssh"
      #- '$SSH_AUTH_SOCK:/ssh-agent'
    environment:
      SSH_AUTH_SOCK: "/ssh-agent"
      APP_NAME: "Docker Laravel"
      APP_ENV: "test"
      APP_KEY: ""
      APP_DEBUG: "true"
      APP_URL: "/"
      APP_TIMEZONE: "UTC"
      DB_ECLIPSE_HOST: "db"
      DB_ECLIPSE_PORT: "3306"
      DB_ECLIPSE_DATABASE: "app_menu"
      DB_ECLIPSE_USERNAME: "homestead"
      DB_ECLIPSE_PASSWORD: "homestead"
    expose:
      - 9000
    depends_on:
      - db

  nginx:
    build:
      context: "./docker/nginx"
    ports:
      - "80:80"
    environment:
      NGINX_PHP_UPSTREAM: php
      # Start URI with /template/...
      NGINX_URI_PREFIX: /
    volumes:
      - "./var/log/nginx:/var/log/nginx"
    depends_on:
      - php

  db:
    build:
      context: ./docker/mysql
    ports:
      - "3306:3306"
    volumes:
      - db_volume:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: "homestead"
      MYSQL_ECLIPSE_HOST: db
      MYSQL_ECLIPSE_DATABASE: "app_menu"
      MYSQL_ECLIPSE_USER: "homestead"
      MYSQL_ECLIPSE_PASSWORD: "homestead"
      MYSQL_AUTH_COMMAND: --default-authentication-plugin=mysql_native_password

  elk:
    image: "willdurand/elk"
    ports:
      - "900:85"
    volumes:
      - "./docker/logstash:/etc/logstash"
      - "./docker/logstash/patterns:/opt/logstash/patterns"
      - "./var/log/laravel:/var/log/laravel"
      - "./var/log/nginx:/var/log/nginx"

volumes:
  db_volume:

and following is my Dockerfile

FROM php:7.3-fpm

RUN apt-get update

RUN apt-get install -y libzip-dev git procps unzip

RUN docker-php-ext-install -j$(nproc) zip

RUN pecl install xdebug-3.0.4 && docker-php-ext-enable xdebug

RUN curl -o /tmp/security_checker -L "https://github.com/fabpot/local-php-security-checker/releases/download/v1.0.0/local-php-security-checker_1.0.0_linux_amd64" \
    && mv /tmp/security_checker /usr/bin/local-php-security-checker \
    && chmod +x /usr/bin/local-php-security-checker

# Install composer from docker repo
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql

WORKDIR /app

ADD docker/php/php.ini $PHP_INI_DIR/conf.d/
ADD docker/php/xdebug.ini  $PHP_INI_DIR/conf.d/

EXPOSE 9000

# Likely don't need to force this to the foreground.  If it fails add `-F` option
CMD ["php-fpm"]

php verison: 7.3 Laravel 8

5
  • this is the nginx log while accessing a page. "/etc/nginx/html/index.html" is not found (2: No such file or directory) Commented Nov 15, 2022 at 6:16
  • Can you share the nginx.conf file? Commented Nov 15, 2022 at 6:59
  • user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 2048;multi_accept on;use epoll; } http { server_tokens off;sendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 15;types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream;access_log /dev/stdout;error_log /dev/stderr;gzip on; gzip_disable "msie6";include /etc/nginx/conf.d/*.conf;include /etc/nginx/sites-enabled/*; open_file_cache max=100;client_body_temp_path /tmp 1 2;client_body_buffer_size 256k; client_body_in_file_only off;} daemon off; Commented Nov 15, 2022 at 7:27
  • Agree with Mojtaba's answer below. Nginx conf should be updated to point to PHP application for it to work. Commented Nov 15, 2022 at 8:36
  • Can you please give me a complete nginx.conf contents for Laravel. Sorry I am new to this config entries Commented Nov 16, 2022 at 9:08

1 Answer 1

1

You have to configure your nginx. Nginx default route is /etc/nginx/html/. So you need a route something like this.

location / {
      proxy_pass http://php:9000/;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host $host;
      proxy_http_version 1.1;
      proxy_set_header Connection "Keep-Alive";
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.