nginx-proxy sets up a container running nginx and docker-gen. docker-gen generates reverse proxy configs for nginx and reloads nginx when containers are started and stopped.
See Automated Nginx Reverse Proxy for Docker for why you might want to use this.
This repo is fork of jwilder/nginx-proxy so you need read origin md file
Include next containers:
- jwilder/nginx-proxy
- docker.elastic.co/elasticsearch/elasticsearch:7.7.1 - for shared access from multiple magento instances (need use different "Elasticsearch Index Prefix" in each instance)
3. docker.elastic.co/kibana/kibana:7.7.1 - data visualization plugin for Elasticsearch(Commented/Disabled) - phpmyadmin/phpmyadmin - manage databases
-
Install docker & docker-compose
-
Add user into group docker & www-data
- Run commands:
$ sudo usermod -aG docker ${USER} $ sudo usermod -aG www-data ${USER}
- Restart system
-
Create docker external network (nginx-proxy - grouped container for reverse nginx, elastic-net - for share elasticsearch, databases - grouped db for phpmyadmin):
$ docker network create nginx-proxy $ docker network create elastic-net $ docker network create databases
-
Add share docker service to
/etc/hosts
file:#share docker service 127.0.0.1 elasticsearch eskibana phpmyadmin
-
Choose shared elasticsearch version & update docker-compose.yml (Default version is 7.7.1). In docker-compose.yml for elasticsearch available
<elasticsearch-verion>
:- elasticsearch5 - 5.6
- elasticsearch6 - 6.8.15
- elasticsearch7 - 7.7.1
elasticsearch: container_name: elasticsearch hostname: elasticsearch.docker build: context: <elasticsearch-verion>/ (example `context: elasticsearch7/`) ...... esdata: image: tianon/true volumes: - ./persistent/<elasticsearch-verion>:/usr/share/elasticsearch/data
-
Update java param for elasticsearch
$ sudo gedit /etc/sysctl.conf
Add 'vm.max_map_count=262144' into file & save it.
-
Up docker containers:
$ docker-compose up -d
P.S. If something went wrong try 1-6 step & force recreate containers:
$ docker-compose up --build --force-recreate Ctrl+C $ docker-compose up -d
Then start any containers you want proxied with an env var VIRTUAL_HOST=subdomain.youdomain.com
In docker-compose.yml file edit phpMyAdmin config if need add additional db:
-
Check full name of docker container you want to add
$ docker network ls
-
Add container full name to phpMyAdmin config (example we already have instance_db_1 and add instance_db_2 to config):
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- 8080:80
environment:
PMA_HOSTS: instance_db_1,instance_db_2
PMA_PORTS: 3306,3306
external_links:
- instance_db_1
- instance_db_2
networks:
- databases
http://elasticsearch:9200
http://eskibana:5601
http://phpmyadmin:8080
If your container exposes multiple ports, nginx-proxy will default to the service running on port 80. If you need to specify a different port, you can set a VIRTUAL_PORT env var to select a different one. If your container only exposes one port and it has a VIRTUAL_HOST env var set, that port will be selected.
- Delete container not used longer that a week:
$ docker ps --filter "status=exited" | grep -E "Exited .*week[s]? ago" | awk '$2 != "tianon/true" {print $1}' | xargs --no-run-if-empty docker rm
- Some time docker return 'random' ip then varnish ask for 'web' container ip - because all varnish & web container grouped in nginx-proxy network docker not clear know what exactly 'web' container want specific 'varnish' container.