E
E
EVOSandru62020-05-20 01:39:52
Nginx
EVOSandru6, 2020-05-20 01:39:52

How to make nginx look in the right folder of Laravel project wrapped in Docker?

Hello.

There is a Laravel project with this docker-compose :

version: '3.7'
services:
  php-fpm:
    container_name: crm_php-fpm
    build:
      context: .
      dockerfile: Dockerfile.php-fpm.${ENV}
    volumes:
      - ./app:/var/www
    environment:
      - REDIS_PORT=6379
      - REDIS_HOST=redis
      - DB_CONNECTION=pgsql
      - DB_PORT=5432
      - DB_HOST=pgsql
    ports:
      - 9001:9000
  php-cli:
    container_name: crm_php-cli
    build:
      context: .
      dockerfile: Dockerfile.php-cli.${ENV}
    volumes:
      - ./app:/var/www
    environment:
      - REDIS_PORT=6379
      - REDIS_HOST=redis
      - DB_CONNECTION=pgsql
      - DB_PORT=5432
      - DB_HOST=pgsql
    restart: always
    tty: true
  pgsql:
    container_name: crm_pgsql
    image: postgres:9.6-alpine
    environment:
      - POSTGRES_USER=app
      - POSTGRES_PASSWORD=app
      - POSTGRES_DATABASE=secret
    ports:
      - 54321:5432
    volumes:
      - ././storage/postgres:/var/lib/postgresql/data
  node:
    container_name: crm_node
    image: node:10.11-jessie
    volumes:
        - ${APP_PATH_HOST}:/var/www
    working_dir: /var/www
    tty: true
  redis:
    container_name: crm_redis
    image: redis:5.0
    ports:
      - 63793:6379


Early nginx was present in the container and it was a working option.
But for some reason I had to bring it outside.

Here is the NGINX config.

server
{
    listen 82;

    index index.php index.html;
    root /home/andrey/PhpStormProjects/crm/app;

    location / {
        try_files $uri /index.php?$args;
    }

    location /docs {
        try_files $uri $uri/;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass localhost:9001;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}


I restart Nginx without errors, I throw a request:
curl localhost:82

and I catch:

File not found.

The structure of the crm project is as follows:
- Docker files and all sorts of docker packs
- .env
- app (here is the standard Laravel project , inside which is another app folder as usual)

What could be the reason?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fortop, 2020-05-20
@Fortop

I have no idea why you moved nginx separately, but the simplest solution to your problem is to mount just the code in the nginx container.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question