varnish.local.php
<?php
return [
'acsi_varnish' => [
'clients' => [
'cache' => [
'endpoint' => [
'host' => 'dev-varnish',
'port' => '8443',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
],
],
],
],
];
default.vcl
vcl 4.1;
backend default {
.host = "dev";
.port = "8080";
}
docker-compose-template.yml
version: '3.7'
services:
dev:
image: dev:centos7
container_name: dev
hostname: dev
volumes:
- ${HOST_BIND_MOUNT_DIR}:${CONTAINER_MOUNT_DIR}
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
networks:
dev-online:
ipv4_address: 172.100.0.2
ports:
- 443:443
# - 6082:6082
- 9001:9001
- 5672:5672
- 15672:15672
- 29015:29015
extra_hosts:
- dev:127.0.0.1
- dev-mysql:172.100.0.3
- dev-mongo-3:172.100.0.4
- dev-mongo-4:172.100.0.5
- dev-solr-6:172.100.0.6
- dev-solr-8:172.100.0.7
- dev-rethinkdb:172.100.0.8
- dev-varnish:172.100.0.10
dev-mysql:
image: dev-mysql-5.7:latest
container_name: dev-mysql
hostname: dev-mysql
user: "${V_UID}:${V_GID}"
volumes:
- ${HOST_BIND_MOUNT_DIR_MYSQL}:${CONTAINER_MOUNT_DIR_MYSQL}
networks:
dev-online:
ipv4_address: 172.100.0.3
ports:
- 3306:3306
environment:
- MYSQL_ROOT_PASSWORD:${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE:${MYSQL_DATABASE}
extra_hosts:
- dev:172.100.0.2
- dev-mysql:127.0.0.1
- dev-mongo-3:172.100.0.4
- dev-mongo-4:172.100.0.5
- dev-solr-6:172.100.0.6
- dev-solr-8:172.100.0.7
- dev-rethinkdb:172.100.0.8
- dev-memcached:172.100.0.9
- dev-varnish:172.100.0.10
dev-mongo-3:
image: mongo-3.0:dev
container_name: dev-mongo-3
hostname: dev-mongo-3
volumes:
- ${HOST_BIND_MOUNT_DIR_MONGO_3}:${CONTAINER_MOUNT_DIR_MONGO}
privileged: true
networks:
dev-online:
ipv4_address: 172.100.0.4
ports:
- 27017:27017
environment:
- MYSQL_ROOT_PASSWORD="${MYSQL_ROOT_PASSWORD}"
- MYSQL_DATABASE="${MYSQL_DATABASE}"
extra_hosts:
- dev:172.100.0.2
- dev-mysql:172.100.0.3
- dev-mongo-3:127.0.0.1
- dev-mongo-4:172.100.0.5
- dev-solr-6:172.100.0.6
- dev-solr-8:172.100.0.7
- dev-rethinkdb:172.100.0.8
- dev-memcached:172.100.0.9
- dev-varnish:172.100.0.10
dev-mongo-4:
image: mongo-4.4:dev
container_name: dev-mongo-4
hostname: dev-mongo-4
user: "${V_UID}:${V_GID}"
volumes:
- ${HOST_BIND_MOUNT_DIR_MONGO_4}:${CONTAINER_MOUNT_DIR_MONGO}
privileged: true
networks:
dev-online:
ipv4_address: 172.100.0.5
ports:
- 27018:27017
environment:
- MYSQL_ROOT_PASSWORD="${MYSQL_ROOT_PASSWORD}"
- MYSQL_DATABASE="${MYSQL_DATABASE}"
extra_hosts:
- dev:172.100.0.2
- dev-mysql:172.100.0.3
- dev-mongo-3:172.100.0.4
- dev-mongo-4:127.0.0.1
- dev-solr-6:172.100.0.6
- dev-solr-8:172.100.0.7
- dev-rethinkdb:172.100.0.8
- dev-memcached:172.100.0.9
- dev-varnish:172.100.0.10
dev-solr-6:
image: solr-6.6:dev
container_name: dev-solr-6
hostname: dev-solr-6
networks:
dev-online:
ipv4_address: 172.100.0.6
ports:
- 8983:8983
extra_hosts:
- dev:172.100.0.2
- dev-mysql:172.100.0.3
- dev-mongo-3:172.100.0.4
- dev-mongo-4:172.100.0.5
- dev-solr-6:127.0.0.1
- dev-solr-8:172.100.0.7
- dev-rethinkdb:172.100.0.8
- dev-memcached:172.100.0.9
- dev-varnish:172.100.0.10
dev-solr-8:
image: solr-8.6:dev
container_name: dev-solr-8
hostname: dev-solr-8
user: "${V_UID}:${V_GID}"
volumes:
- ${HOST_BIND_MOUNT_DIR_SOLR}:${CONTAINER_MOUNT_DIR_SOLR_8}
networks:
dev-online:
ipv4_address: 172.100.0.7
ports:
- 8984:8983
environment:
- SOLR_HEAP=2g
extra_hosts:
- dev:172.100.0.2
- dev-mysql:172.100.0.3
- dev-mongo-3:172.100.0.4
- dev-mongo-4:172.100.0.5
- dev-solr-6:172.100.0.6
- dev-solr-8:127.0.0.1
- dev-rethinkdb:172.100.0.8
- dev-memcached:172.100.0.9
- dev-varnish:172.100.0.10
dev-rethinkdb:
image: rethinkdb
container_name: dev-rethinkdb
hostname: dev-rethinkdb
user: "${V_UID}:${V_GID}"
volumes:
- ${HOST_BIND_MOUNT_DIR_RETHINKDB}:${CONTAINER_MOUNT_DIR_RETHINKDB}
networks:
dev-online:
ipv4_address: 172.100.0.8
ports:
- 28015:28015
- 8080:8080
extra_hosts:
- dev:172.100.0.2
- dev-mysql:172.100.0.3
- dev-mongo-3:172.100.0.4
- dev-mongo-4:172.100.0.5
- dev-solr-6:172.100.0.6
- dev-solr-8:172.100.0.7
- dev-rethinkdb:127.0.0.1
- dev-memcached:172.100.0.9
- dev-varnish:172.100.0.10
dev-memcached:
image: memcached
container_name: dev-memcached
hostname: dev-memcached
user: "${V_UID}:${V_GID}"
networks:
dev-online:
ipv4_address: 172.100.0.9
ports:
- 11211:11211
extra_hosts:
- dev:172.100.0.2
- dev-mysql:172.100.0.3
- dev-mongo-3:172.100.0.4
- dev-mongo-4:172.100.0.5
- dev-solr-6:172.100.0.6
- dev-solr-8:172.100.0.7
- dev-rethinkdb:172.100.0.8
- dev-memcached:127.0.0.1
- dev-varnish:172.100.0.10
dev-varnish:
image: varnish:7.2.1-alpine
container_name: dev-varnish
hostname: dev-varnish
user: '0'
volumes:
- "./default.vcl:/etc/varnish/default.vcl"
ports:
- "6082:8443"
tmpfs:
- /var/lib/varnish/varnishd:exec
networks:
dev-online:
ipv4_address: 172.100.0.10
extra_hosts:
- dev:172.100.0.2
- dev-mysql:172.100.0.3
- dev-mongo-3:172.100.0.4
- dev-mongo-4:172.100.0.5
- dev-solr-6:172.100.0.6
- dev-solr-8:172.100.0.7
- dev-rethinkdb:172.100.0.8
- dev-varnish:127.0.0.1
- dev-memcached:172.100.0.9
networks:
dev-online:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.100.0.0/24
I am trying to containerise the varnish service which is already working in "dev" container, but after i containerise, i don't see it is working, i am not sure what is going wrong here.
the connection should work in the below flow
https://loadwebsite.com -> "dev" container -> "dev-varnish" container -> "dev" container
the browser throws the error below
"Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later."
CodePudding user response:
- Please run run
docker compose ps dev-varnish
to see if thevarnishd
process is running - Finally run
docker compose exec -ti dev-varnish varnishlog -g request
to run thevarnishlog
binary inside the container and output the logs
Please attach the output from varnishlog -g request
to your question. This will clarify how Varnish is behaving and can lead to a possible solution.