Lacquer caching of POST requests

What I'm doing is a little crazy, but since the GET requests are very strict, solr uses POST requests for the URL /solr/selectto execute a “semantically” GET.

I am trying to put a varnish in front of solr to do some caching. I put this in a function vcl_recv:

 if (!(req.request == "GET" || req.request == "HEAD" ||
     (req.request == "POST" && req.url == "/solr/select"))) {
     /* We only deal with GET and HEAD by default */
     /* Modified to support POST to /solr/select */
     return (pass);
 }

and varnish now tries to handle this, except that it automatically converts POST to GET.

I know that all this is pretty funny and far from any best practices, but is there anyway an easy way to use the varnish this way?

+5
source share
2 answers

req.POST GET POST GET- (, , inline-C) /.

GET- HTTP Varnish, . , URL-, .

+3

.

, Varnish 4.1 VMODS , , POST .

, Varnish 5 .

, Docker :

Dockerfile:

FROM alpine:3.7

LABEL maintainer lloiacono@*******.com

RUN apk update \
    && apk add --no-cache varnish \
    && apk add git \
    && git clone https://github.com/varnish/varnish-modules.git \
    && apk add automake && apk add varnish-dev \
    && apk add autoconf && apk add libtool \
    && apk add py-docutils && apk add make \
    && cd varnish-modules/ \
    && ./bootstrap && ./configure && make && make install

COPY start.sh /usr/local/bin/docker-app-start

RUN chmod +x /usr/local/bin/docker-app-start

CMD ["docker-app-start"]

start.sh

#!/bin/sh
set -xe

varnishd -a :80 -f /etc/varnish/default.vcl -s malloc,256m
varnishlog
+1
source

All Articles