docker Nginx ES2en ES3en Single machine multi site deployment method

  • 2020-12-09 01:11:14
  • OfStack

Various methods have been tried on the Internet to deal with single NGINX container in a single machine, single ES2en-ES3en container deployed to multiple sites, but they are not successful.

After reflection and summary, two methods have been successfully implemented:

Single Nginx, multiple ES8en-ES9en Single Nginx, single ES11en-ES12en

Single Nginx, multiple ES15en-ES16en

docker-compose.yml


version: '2'
 
services:
  nginx-1.15.1:
    image: nginx:laster
    ports:
      - "80:80"
    volumes:
      - ./htdocs:/usr/local/nginx/html
      - ./etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./etc/nginx/conf.d:/etc/nginx/conf.d
      - ./log/nginx:/var/log/nginx
    networks:
      - leoedu-network
  php-fpm-a:
    image: php-fpm:laster
    volumes:
      - ./htdocs/a.com:/var/www/html
    networks:
      - leoedu-network
  php-fpm-b:
    image: php-fpm:laster
    volumes:
      - ./htdocs/b.com:/var/www/html
    networks:
      - leoedu-network
 
networks:
  leoedu-network:
    driver: bridge

nginx profile:


server {
  listen    80;
  charset utf-8;
  server_name a.com;
 
  root /usr/local/nginx/html/a.com;
  index index.html index.htm index.php;
 
  error_log /var/log/nginx/a.com-error.log;
  access_log /var/log/nginx/a.com-access.log;
 
 
  location ~ \.php$ {
    fastcgi_pass  php-fpm-a:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include    fastcgi_params;
  }
}

Single Nginx, single ES28en-ES29en

docker-compose.yml


version: '2'
 
services:
  nginx-1.15.1:
    image: nginx:laster
    ports:
      - "80:80"
    volumes:
      - ./htdocs:/usr/local/nginx/html
      - ./etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./etc/nginx/conf.d:/etc/nginx/conf.d
      - ./log/nginx:/var/log/nginx
    networks:
      - leoedu-network
  php-fpm-7.2.5:
    image: php-fpm:laster
    volumes:
      - ./htdocs:/var/www/html
    networks:
      - leoedu-network
networks:
  leoedu-network:
    driver: bridge

The key points for the NGINX configuration are:


astcgi_param SCRIPT_FILENAME /var/www/html/nick.com/$fastcgi_script_name;

For specific reasons, I will make up later when I am free. This is a pure record


Related articles: