Dockerfile: FastCGI выбрасывает основной сценарий неизвестно "при чтении заголовка ответа из вышестоящей ошибки - PullRequest
0 голосов
/ 04 сентября 2018

Я создаю проект laravel с помощью Docker Compose, используя следующую настройку:

докер-compose.yml

version: '2' 

services:
  app:
    build:
      context: ./
      dockerfile: app.dockerfile
    working_dir: /var/www
    volumes:
      - ./:/var/www
    environment:
      - "DB_PORT=3306"
      - "DB_HOST=database"

  web:
    build:
      context: ./
      dockerfile: web.dockerfile
    working_dir: /var/www
    volumes_from:
      - app
    ports:
      - 8001:80

  database:
    image: mysql:5.7
    volumes:
      - dbdata:/var/lib/mysql
    environment:
      - "MYSQL_DATABASE=xxxx"
      - "MYSQL_USER=xxxx"
      - "MYSQL_PASSWORD=xxxx"
      - "MYSQL_ROOT_PASSWORD=xxxx"
    ports:
      - 33061:3306

volumes:
  dbdata:

nginx.conf

events {
  worker_connections  2048;
}

http {
    server {
        listen 80;
        index index.php index.html;
        root /var/www;

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

        location ~ \.css {
            add_header Content-Type text/css;
        }

        location ~ \.js {
            add_header Content-Type application/x-javascript;
        }

        location ~ ^/(assets/|css/|js/|index.html) {
            root /var/www;
            index index.html;
            access_log off;
        }

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

web.dockerfile

FROM nginx:alpine

RUN apk --update add supervisor

RUN addgroup -g 1000 -S www-data \
    && adduser -u 1000 -D -S -G www-data www-data

RUN rm /var/cache/apk/*

COPY nginx.conf /etc/nginx/nginx.conf
COPY supervisord-web.conf /etc/supervisord.conf

ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]

Запуск $: docker-compose up работает без нареканий, но когда я перехожу к своему http://localhost:8001, я получаю следующую ошибку:

app_1       | 172.23.0.4 -  04/Sep/2018:13:06:29 +0000 "GET /index.php" 404
web_1       | 2018/09/04 13:06:29 [error] 9#9: *4 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.23.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://172.23.0.2:9000", host: "localhost:8001"
web_1       | 172.23.0.1 - - [04/Sep/2018:13:06:29 +0000] "GET / HTTP/1.1" 404 27 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
web_1       | 2018/09/04 13:06:31 [error] 9#9: *4 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.23.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://172.23.0.2:9000", host: "localhost:8001"
web_1       | 172.23.0.1 - - [04/Sep/2018:13:06:31 +0000] "GET / HTTP/1.1" 404 27 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
app_1       | 172.23.0.4 -  04/Sep/2018:13:06:31 +0000 "GET /index.php" 404

Сначала я подумал, что моя папка "public_html" по умолчанию неправильная, но я думаю, что она совпадает с working_dir (в службах приложения) и моим nginx.conf

Я не уверен, что мне здесь не хватает, я надеюсь, что смогу получить ответ здесь. Спасибо за помощь.

...