Git Product home page Git Product logo

docker-varnish's Introduction

Varnish Docker container

Centos 7
Varnish 4.x

Usage

To use this container, you will need to provide your custom config.vcl (which is usually the case).

docker run -d \
  --link web-app:backend-host \
  --volumes-from web-app \
  --env 'VCL_CONFIG=/data/path/to/varnish.vcl' \
  million12/varnish

In the above example we assume that:

  • You have your application running inside web-app container and web server there is running on port 80 (although you don't need to expose that port, as we use --link and varnish will connect directly to it)
  • web-app container has /data volume with varnish.vcl somewhere there
  • web-app is aliased inside varnish container as backend-host
  • Your varnish.vcl should contain at least backend definition like this:
backend default {
    .host = "backend-host";
    .port = "80";
}

Environmental variables

You can configure Varnish daemon by following env variables:

VCL_CONFIG /etc/varnish/default.vcl
CACHE_SIZE 64m
VARNISHD_PARAMS -p default_ttl=3600 -p default_grace=3600

Author(s)


Sponsored by Typostrap.io - the new prototyping tool for building highly-interactive prototypes of your website or web app. Built on top of TYPO3 Neos CMS and Zurb Foundation framework.

docker-varnish's People

Contributors

gigaroby avatar ibobo avatar pozgo avatar ryzy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

docker-varnish's Issues

How can I reload default.vcl without restarting?

  1. I tried to run varnish_reload_vcl, but I got connection failed.

  2. I changed VARNISHD_PARAMS to -p default_grace=3600 -T 127.0.0.1:6082.

  3. Now, when I run varnish_reload_vcl the script can connect, but it fails to authenticate:

    screen shot 2016-07-07 at 12 24 31

The secret file is there, so the path is correct. What else could be wrong? What should I try or debug?

Thanks!

enable syslog

Hello,
I'm trying to use syslog in my vcl file but that doesn't work.
I can't find the /var/log/syslog file.
How can I make it works please?

vcl 4.0;
import std;
sub vcl_recv {
    if (req.method != "GET" && req.method != "HEAD") {
        std.syslog(180, "BAN " + client.ip + " METHOD " +req.method);
        return (pass);
   }
}

bind(): Cannot assign requested address

When running from docker-compose, I get the following:

bind(): Cannot assign requested address
varnish_dydra_1  | child (14) Started
varnish_dydra_1  | Child (14) said Child starts

Any idea what the problem with bind() is?

Image does not appear to have ESI tags enabled

We are running this Docker Image on a Plesk environment with a custom Magento 2 VCL mapped for starting the image. Everything works well except for ESI includes. A particular case is the menu of a website is not available with Varnish on and a tag like the one below appears instead of the menu

<esi:include src="http://www.domain.com/page_cache/block/esi/blocks/..."></esi:include>

The problem seems to be in the DAEMON_OPTS section of the Image as we discussed with some developers and they suggested we add this in DAEMON_OPTS section.

    -p feature=+esi_ignore_other_elements \
    -p feature=+esi_disable_xml_check \
    -p feature=+esi_ignore_https \
    -p http_resp_hdr_len=16k \
    -p http_resp_size=64k \
    -p workspace_backend=64k \

We tried to add DAEMON_OPTS as a parameter for Docker but it is not working

69bdf074-6be3-494e-94fd-f356459e5d0f

We also searched for the option to enable them directly in the Docker Image config files and we found this option in 2 locations

Location 1
./etc/varnish/varnish.params

For this we added this line

DAEMON_OPTS="-p feature=+esi_ignore_other_elements -p feature=+esi_disable_xml_check -p feature=+esi_ignore_https -p http_resp_hdr_len=16k -p http_resp_size=64k -p workspace_backend=64k"

Location 2

./usr/lib/systemd/system/varnish.service

For this the config we tried to include the options directly in the ExecStart lines like so

Original config

ExecStart=/usr/sbin/varnishd \
        -P /var/run/varnish.pid \
        -f $VARNISH_VCL_CONF \
        -a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
        -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
        -S $VARNISH_SECRET_FILE \
        -u $VARNISH_USER -g $VARNISH_GROUP \
        -s $VARNISH_STORAGE \
        $DAEMON_OPTS

New Config

ExecStart=/usr/sbin/varnishd \
        -P /var/run/varnish.pid \
        -f $VARNISH_VCL_CONF \
        -a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
        -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
        -S $VARNISH_SECRET_FILE \
        -u $VARNISH_USER -g $VARNISH_GROUP \
        -s $VARNISH_STORAGE \
    -p feature=+esi_ignore_other_elements \
    -p feature=+esi_disable_xml_check \
    -p feature=+esi_ignore_https \
    -p http_resp_hdr_len=16k \
    -p http_resp_size=64k \
    -p workspace_backend=64k \
        $DAEMON_OPTS

Basically $DAEMON_OPTS should have included the options from the previous file yet none of the options are working.

The VCL contains the proper esi tag like so

sub vcl_backend_response {

    set beresp.grace = 3d;

    if (beresp.http.content-type ~ "text") {
       **set beresp.do_esi = true;**
    }

Add CI tests

The tests should also cover passing commands like these described in #1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.