How to have multiple istances?
Is possible to have multiple istances of magento website on the same server? What I need to change?
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.
- Request for site1.example.com: Nginx on port 80 -> Site 1 (127.0.0.2:80)
- Request for site2.example.com: Nginx on port 80 -> Site 1 (127.0.0.3:80)
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.