Skip to content

Instantly share code, notes, and snippets.

@gquintard
gquintard / vmod-request docker
Last active May 12, 2022 07:43
vmod-request docker
FROM ubuntu:focal
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true
RUN apt-get update
RUN apt-get install -y curl cargo git pkg-config libssl-dev clang
RUN curl -s https://packagecloud.io/install/repositories/varnishcache/varnish71/script.deb.sh | bash
RUN apt-get install -y varnish-dev
RUN git clone https://github.com/gquintard/vmod_reqwest.git
WORKDIR /vmod_reqwest
FROM debian:stretch-slim
RUN apt update && \
echo > /etc/apt/sources.list.d/varnish.list deb https://packagecloud.io/varnishcache/varnish62/debian/ stretch main && \
echo >> /etc/apt/sources.list.d/varnish.list deb-src https://packagecloud.io/varnishcache/varnish62/debian/ stretch main && \
apt-get install devscripts dpkg-dev curl gnupg apt-transport-https -y && \
curl -L https://packagecloud.io/varnishcache/varnish62/gpgkey | apt-key add - && \
apt update && \
mkdir /tmp/workdir && \
cd /tmp/workdir && \
FROM debian:stretch-slim
RUN apt update && \
echo > /etc/apt/sources.list.d/varnish.list deb https://packagecloud.io/varnishcache/varnish62/debian/ stretch main && \
echo >> /etc/apt/sources.list.d/varnish.list deb-src https://packagecloud.io/varnishcache/varnish62/debian/ stretch main && \
apt-get install devscripts dpkg-dev curl gnupg apt-transport-https -y && \
curl -L https://packagecloud.io/varnishcache/varnish62/gpgkey | apt-key add - && \
apt update && \
mkdir /tmp/workdir && \
cd /tmp/workdir && \
FROM debian:stretch-slim
RUN apt update && \
echo > /etc/apt/sources.list.d/varnish.list deb https://packagecloud.io/varnishcache/varnish62/debian/ stretch main && \
echo >> /etc/apt/sources.list.d/varnish.list deb-src https://packagecloud.io/varnishcache/varnish62/debian/ stretch main && \
apt-get install devscripts dpkg-dev curl gnupg apt-transport-https -y && \
curl -L https://packagecloud.io/varnishcache/varnish62/gpgkey | apt-key add - && \
apt update && \
mkdir /tmp/workdir && \
cd /tmp/workdir && \
vcl 4.0; /* don't mind that, that's the vcl version, not the varnish version*/
import std;
backend api {
.host = "192.168.1.123";
}
backend api_limited {
.host = "192.168.1.123";
version: '2'
services:
varnish:
image: "varnish-img"
hitch:
image: "hitch-img"
ports:
- "1443:443"
#!/bin/bash
# usage: token_checker.sh KEY [STRING....]
key="$1"
shift
s=
for i in "$@"; do
s="$s$i"
done
@gquintard
gquintard / foo.vtc
Created March 17, 2017 13:30
Test XFF ip extraction
varnishtest "XFF test"
server s1 {} -start
varnish v1 -vcl+backend {
sub vcl_recv {
return (synth(200));
}
@gquintard
gquintard / sticky.vtc
Created March 10, 2017 14:49
Varnish sticky session (new)
varnishtest "Test cookie vmod"
server s1 {
rxreq
txresp -hdr "server: s1" -hdr "set-cookie: id=123;"
rxreq
txresp -hdr "server: s1"
rxreq
@gquintard
gquintard / gist:e11ff0e44c3fbd3530540385ee045ae4
Created March 10, 2017 13:52
Varnish sticky session (prefix)
varnishtest "Test cookie vmod"
server s1 {
rxreq
txresp -hdr "set-cookie: id=123;"
rxreq
expect req.http.cookie == "id=123;"
txresp -hdr "server: s1"