Running 2 sites on docker-nginx-php server

I’m using Docker and serving a PHP API server with nginx and mysql. Now I’m trying to add a separated static website but failed to do so by modiying nginx.conf. The following is my folder structure.

+ 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

Here is my nginx conf.

  • Docker stop exiting with 0
  • Linking containers between task definitions in AWS ECS?
  • docker container port accessed from another container
  • How to rename a Bluemix namespace (container registry)?
  • Docker Rails app fails to be served - curl: (56) Recv failure: Connection reset by peer
  • aws container service \ how dockers configured for communicating with each other
  • 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;
        }
    
    }
    

    I can access api.example.com and everything works fine. But when I go to example.com, it shows 404 not found. nginx/1.114 (Does it have anything to do with docker-compose.yml?)

    Thanks!

  • Trouble running docker registry in insecure mode on Ubuntu 16.04
  • How to get RAM, CPU, network usage on a specific process on a container
  • Liberty Admin Center shows Docker server as running while it is not
  • Getting docker working in daemon mode for a tahoe-lafs storage node?
  • How to avoid recreation of a linked container with docker-compose?
  • Docker/CI: Get access to nodeJS app, which is created in another stage
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.