andreaskoch / dockerized-magento

A dockerized Magento Community Edition 1.9.x
BSD 3-Clause "New" or "Revised" License
278 stars 144 forks source link

How to have multiple istances? #55

Open olivierognn opened 6 years ago

olivierognn commented 6 years ago

Is possible to have multiple istances of magento website on the same server? What I need to change?

andreaskoch commented 6 years ago

Hi @olivierognn. Yes, it is possible to run multiple instances at the same time. You have three options:

Option 1: Multiple Public IPs

If your server has multiple IP addresses you can bind the web ports of the different instances to the different IP addresses (see: docker-compose.yml)

Instance 1:

nginx:
  image: nginx:latest
  ports:
    - "192.168.2.2:80:80"
    - "192.168.2.2:443:443"

Instance 2:

nginx:
  image: nginx:latest
  ports:
    - "192.168.2.3:80:80"
    - "192.168.2.3:443:443"

Option 2: Using High Ports

If you don't have have multiple IP addresses available you can use different public ports - this is only a viable option for internally used shops:

Instance 1:

nginx:
  image: nginx:latest
  ports:
    - "80:80"
    - "443:443"

Instance 2:

nginx:
  image: nginx:latest
  ports:
    - "6080:80"
    - "60443:443"

Option 3: Reverse Proxy

Or can can put a reverse proxy in front of the two instances which routes the traffic based on the hostname.

In that case I would recommend to run the Nginx natively und bind the two instances to local IP addreses (e.g. 127.0.0.2, 127.0.0.3):

Instance 1:

nginx:
  image: nginx:latest
  ports:
    - "127.0.0.2:80:80"
    - "127.0.0.2:443:443"

Instance 2:

nginx:
  image: nginx:latest
  ports:
    - "127.0.0.3:80:80"
    - "127.0.0.3:443:443"

Whenever possible I would use Option 1. That's easiest to setup and maintain.