在docker nginx php服务器上运行2个站点

在docker nginx php服务器上运行2个站点,php,amazon-web-services,nginx,docker,containers,Php,Amazon Web Services,Nginx,Docker,Containers,我正在使用Docker并使用nginx和mysql为PHPAPI服务器提供服务。现在我正试图添加一个单独的静态网站,但通过修改nginx.conf失败了。下面是我的文件夹结构 + images |+ php |-- Dockerfile ||+ app ||-+ public |||-- index.php ||+ home <-- TRYING TO GET THIS WORKING (Same level as app folder) ||-- index.html <-- T

我正在使用Docker并使用nginx和mysql为PHPAPI服务器提供服务。现在我正试图添加一个单独的静态网站,但通过修改nginx.conf失败了。下面是我的文件夹结构

+ images
|+ php
|-- Dockerfile
||+ app
||-+ public
|||-- index.php
||+ home <-- TRYING TO GET THIS WORKING (Same level as app folder)
||-- index.html  <-- TRYING TO THIS WORKING 
|+ nginx
|-- nginx.conf
|-- Dockerfile
- README.md
- docker-compose.yml
我可以访问api.example.com,一切正常。但当我访问example.com时,它显示404未找到。nginx/1.114(它是否与docker compose.yml有关?)


谢谢

你能把你的docker文件和docker-compose.yml也粘贴一下吗?另外,您是否可以使用“tree”命令重新生成文件夹结构列表(当前很难读取)?顺便说一句,我的第一个猜测是nginx conf('root/home')中的路径错误,但要确认它,需要Dockerfile。第二件事是,您可能应该为静态文件使用不同的容器,并使用compose启动这两个容器。
server {
  listen 80;
  server_name api.example.com;
  root /app/public;
  index index.php index.htm index.html;

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

  location /index.php {
      include fastcgi_params;
      fastcgi_connect_timeout 10s;
      fastcgi_read_timeout 10s;
      fastcgi_buffers 256 4k;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_pass php:9000;
  }

    add_header Access-Control-Allow-Origin "*";
    add_header Access-Control-Allow-Methods "GET, OPTIONS";
    add_header Access-Control-Allow-Headers "origin, authorization, accept";
}

server {
    listen 80;
    server_name example.com www.example.com;
    root /home;
    index index.htm index.html

    location / {
        try_files $uri $uri/ /index.html;
    }

}