大网数据广告活动
服务器运维问答

NGINX server says File not found

· 52CE 我爱测

Am trying to learn the microservice architecture by building out services using lumen and docker. I have folder structure like this ./ ./base_service ./base_service/base.docker ./user_service ./user_service/user.docker ./auth_ser…

问题原文

原帖链接 · MrFoh · CC BY-SA 3.0

Am trying to learn the microservice architecture by building out services using lumen and docker. I have folder structure like this

./
./base_service
./base_service/base.docker
./user_service
./user_service/user.docker
./auth_service
./auth_service/auth.docker
./gateway.docker
./vhost.conf
./docker-compose.yml

Each service directory is a lumen app This what is my docker-compose.yml file look like

version: '2'
services:
    gateway:
      build:
        context: ./
        dockerfile: web.docker
      volumes:
        - ./:/var/www
      ports:
        - "8080:80"
      links:
        - base_service
        - auth_service
        - user_service
    base_service:
      build:
        context: ./base_service
        dockerfile: base.docker
      volumes:
          - ./:/var/www
      links:
          - broker
    auth_service:
      build:
        context: ./auth_service
        dockerfile: auth.docker
      volumes:
          - ./:/var/www
      links:
          - broker
    user_service:
      build:
        context: ./user_service
        dockerfile: user.docker
      volumes:
          - ./:/var/www
      links:
          - broker
    broker:
        image: redis:3.0
        ports:
            - "63791:6379"

The gateway.docker

FROM nginx

ADD ./vhost.conf /etc/nginx/conf.d/default.conf

WORKDIR /var/www

my vhost.conf for nginx

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

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

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

The docker files for the services just fetch a PHP7-fpm image

FROM php:7-fpm

RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client \
  && docker-php-ext-install mcrypt pdo_mysql

WORKDIR /var/www

Running the docker-compose up -d command and navigating to http://localhost:8080, i get a page saying "File not found". This my first time attempting a microservices architecture, so somewhat out of my depth with the configuration of the whole setup, any help or guidance will be greatly appreciated.

已采纳解答

原帖链接 · Brahma Kumar Krishna · CC BY-SA 3.0

I had the similar problem as I tried to imitate the things stated : here. Finally, I figured out that the problem was I had to put all those files in the PROJECT ROOT (and not create a project inside it!). After making these changes, I was able to work on my project flawlessly. Hope this helps you too.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-10-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。