docker4drupal
docker4drupal copied to clipboard
Swarm Varnish
Codebase
mounted codebase
Host OS
CentOS
Docker info output
Containers: 13
Running: 7
Paused: 0
Stopped: 6
Images: 56
Server Version: 18.03.0-ce
Storage Driver: overlay
Backing Filesystem: extfs
Supports d_type: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
NodeID: ibi1uendqffht27anh9109ozk
Is Manager: true
ClusterID: tcrprkgx4u8ol2hx53b68rigo
Managers: 1
Nodes: 4
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 3
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 10.0.0.52
Manager Addresses:
10.0.0.52:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-693.21.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 2.708GiB
Name: OE-manager
ID: JNJN:DPCN:VIE4:3Z3M:F2NU:LBP5:W4JU:RVRL:NYDP:6JKJ:UXHH:3FYF
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Docker compose file
services:
php:
image: wodby/drupal-php:7.1
environment:
PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
PHP_FPM_LOG_LEVEL: debug
volumes:
- /srv/www/html/staging/example/web:/var/www/html
- /srv/www/docker/staging/example/settings.php:/var/www/html/sites/default/settings.php
networks:
- traefik
deploy:
placement:
constraints:
- node.role == worker
replicas: 3
nginx:
image: wodby/drupal-nginx:7-1.13
depends_on:
- staging_example_php
environment:
NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off"
NGINX_ERROR_LOG_LEVEL: debug
NGINX_BACKEND_HOST: staging_example_php
NGINX_SERVER_NAME: staging.example.net
NGINX_SERVER_ROOT: /var/www/html
volumes:
- /srv/www/html/staging/example/web:/var/www/html
networks:
- traefik
deploy:
placement:
constraints:
- node.role == worker
replicas: 3
labels:
- 'traefik.backend=staging_example_nginx'
- 'traefik.port=80'
- 'traefik.frontend.rule=Host:nginx.staging.example.net'
- 'traefik.docker.network=traefik_net'
- 'traefik.backend.loadbalancer.method=wrr'
- 'traefik.backend.loadbalancer.stickiness=true'
- 'traefik.backend.loadbalancer.swarm=true'
varnish:
image: wodby/drupal-varnish:4.1-2.4.0
depends_on:
- staging_example_nginx
environment:
VARNISH_SECRET: secret
VARNISH_BACKEND_HOST: staging_example_nginx
VARNISH_BACKEND_PORT: 80
VARNISH_EXCLUDE_URLS: ^(/update\\.php|/([a-z]{2}/)?admin|/([a-z]{2}/)?admin/.*|/([a-z]{2}/)?system/files/.*|/([a-z]{2}/)?flag/.*|.*/core/.*|.*/ajax/.*|.*/ahah/.*)$$
networks:
- traefik
deploy:
placement:
constraints:
- node.role == worker
replicas: 3
labels:
- 'traefik.backend=staging_example_varnish'
- 'traefik.port=6081'
- 'traefik.frontend.rule=Host:staging.example.net'
- 'traefik.docker.network=traefik_net'
- 'traefik.backend.loadbalancer.method=wrr'
- 'traefik.backend.loadbalancer.stickiness=true'
- 'traefik.backend.loadbalancer.swarm=true'
Logs output
Varnish is saying it cannot make a choice between all the ip addresses for nginx (because one is getting created each node and they are all in my network)
I am not sure how to approach this issue. You can set multiple backends in varnish.vcl but since docker auto creates them I am kinda at a loss.
I may have gotten around this. I am still testing but I believe I just needed to join nginx and varnish to there own network on each node not using the overlay driver. Then varnish only sees the one nginx.