-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Default ddev-varnish configuration - The small vcl bit from .lando/varnish.vcl added to default.vcl
- Loading branch information
1 parent
c489643
commit e57d748
Showing
12 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: varnish | ||
repository: ddev/ddev-varnish | ||
version: v0.2.3 | ||
install_date: "2024-08-13T15:59:06+03:00" | ||
project_files: | ||
- docker-compose.varnish.yaml | ||
- varnish | ||
- commands/varnish | ||
global_files: [] | ||
removal_actions: | ||
- | | ||
#ddev-nodisplay | ||
if [ -f docker-compose.varnish_extras.yaml ]; then | ||
if grep -q '#ddev-generated' docker-compose.varnish_extras.yaml; then | ||
rm -f docker-compose.varnish_extras.yaml | ||
else | ||
echo "Unwilling to remove '$DDEV_APPROOT/.ddev/docker-compose.varnish_extras.yaml' because it does not have #ddev-generated in it; you can manually delete it if it is safe to delete." | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
## #ddev-generated | ||
## Description: Control a running Varnish instance | ||
## Usage: varnishadm [flags] [args] | ||
## Example: "ddev varnishadm" | ||
|
||
# This example runs inside the varnish container. | ||
# Note that this requires that /mnt/ddev_config be mounted | ||
# into the varnish container. | ||
|
||
varnishadm "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
## #ddev-generated | ||
## Description: Varnish-cli | ||
## Usage: varnishd [flags] [args] | ||
## Example: "ddev varnishd -d" for CLI in foreground. | ||
## Example: "ddev varnishd -T" to connect with varnishadm or telnet. | ||
## Example: "ddev varnishd -M" to connect back to a listening service pushing the CLI to that service. | ||
|
||
# This example runs inside the varnish container. | ||
# Note that this requires that /mnt/ddev_config be mounted | ||
# into the varnish container. | ||
|
||
varnishd "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
## #ddev-generated | ||
## Description: Display Varnish request histogram | ||
## Usage: varnishhist [flags] [args] | ||
## Example: "ddev varnishhist" | ||
|
||
# This example runs inside the varnish container. | ||
# Note that this requires that /mnt/ddev_config be mounted | ||
# into the varnish container. | ||
|
||
varnishhist "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
## #ddev-generated | ||
## Description: Display Varnish logs | ||
## Usage: varnishlog [flags] [args] | ||
## Example: "ddev varnishlog" | ||
|
||
# This example runs inside the varnish container. | ||
# Note that this requires that /mnt/ddev_config be mounted | ||
# into the varnish container. | ||
|
||
varnishlog "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
## #ddev-generated | ||
## Description: Display Varnish logs in Apache / NCSA combined log format | ||
## Usage: varnishncsa [flags] [args] | ||
## Example: "ddev varnishncsa" | ||
|
||
# This example runs inside the varnish container. | ||
# Note that this requires that /mnt/ddev_config be mounted | ||
# into the varnish container. | ||
|
||
varnishncsa "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
## #ddev-generated | ||
## Description: Display Varnish Cache statistics | ||
## Usage: varnishstat [flags] [args] | ||
## Example: "ddev varnishstat" | ||
|
||
# This example runs inside the varnish container. | ||
# Note that this requires that /mnt/ddev_config be mounted | ||
# into the varnish container. | ||
|
||
varnishstat "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
## #ddev-generated | ||
## Description: Test program for Varnish | ||
## Usage: varnishtest [flags] [args] | ||
## Example: "ddev varnishtest" | ||
|
||
# This example runs inside the varnish container. | ||
# Note that this requires that /mnt/ddev_config be mounted | ||
# into the varnish container. | ||
|
||
varnishtest "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
## #ddev-generated | ||
## Description: Display Varnish log entry ranking | ||
## Usage: varnishtop [flags] [args] | ||
## Example: "ddev varnishtop" | ||
|
||
# This example runs inside the varnish container. | ||
# Note that this requires that /mnt/ddev_config be mounted | ||
# into the varnish container. | ||
|
||
varnishtop "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ddev-generated | ||
services: | ||
varnish: | ||
container_name: ddev-${DDEV_SITENAME}-varnish | ||
image: varnish:6.0 | ||
# These labels ensure this service is discoverable by ddev. | ||
labels: | ||
com.ddev.site-name: ${DDEV_SITENAME} | ||
com.ddev.approot: $DDEV_APPROOT | ||
environment: | ||
# This defines the host name the service should be accessible from. This | ||
# will be sitename.ddev.site. | ||
# This is the first half of the trick that puts varnish "in front of" the | ||
# web container, just by switching the names. | ||
- VIRTUAL_HOST=$DDEV_HOSTNAME | ||
# This defines the ports the service should be accessible from at | ||
# sitename.ddev.site. | ||
- HTTPS_EXPOSE=443:80,8026:8025 | ||
- HTTP_EXPOSE=80:80,8025:8025 | ||
volumes: | ||
# This exposes a mount to the host system `.ddev/varnish` directory where | ||
# your default.vcl should be. | ||
- "./varnish:/etc/varnish" | ||
- ".:/mnt/ddev_config" | ||
depends_on: | ||
- web | ||
# Add mailhog support | ||
expose: | ||
- "8025" | ||
entrypoint: | ||
/usr/local/bin/docker-varnish-entrypoint -a 0.0.0.0:8025 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ddev-generated | ||
# This is the second half of the trick that puts varnish "in front of" the web | ||
# container, just by switching the names. | ||
services: | ||
web: | ||
environment: | ||
- VIRTUAL_HOST=novarnish.drupal-project.ddev.site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# For a more advanced example see https://github.com/mattiasgeniar/varnish-6.0-configuration-templates | ||
vcl 4.1; | ||
import std; | ||
|
||
backend default { | ||
.host = "web"; | ||
.port = "80"; | ||
} | ||
|
||
# @see: https://github.com/wunderio/charts/blob/master/drupal/templates/varnish-configmap-vcl.yaml | ||
# The routine when we deliver the HTTP request to the user | ||
# Last chance to modify headers that are sent to the client. | ||
sub vcl_deliver { | ||
# Called before a cached object is delivered to the client. | ||
|
||
# Add debug header to see if it's a HIT/MISS and the number of hits, disable when not needed. | ||
if (obj.hits > 0) { | ||
set resp.http.X-W-Cache = "HIT"; | ||
set resp.http.X-W-Cache-Hits = obj.hits; | ||
} else { | ||
set resp.http.X-W-Cache = "MISS"; | ||
} | ||
} | ||
|
||
sub vcl_recv { | ||
if (std.port(server.ip) == 8025) { | ||
return (synth(750)); | ||
} | ||
} | ||
|
||
sub vcl_synth { | ||
if (resp.status == 750) { | ||
set resp.status = 301; | ||
set resp.http.location = req.http.X-Forwarded-Proto + "://novarnish." + req.http.Host + req.url; | ||
set resp.reason = "Moved"; | ||
return (deliver); | ||
} | ||
} |