{
"_id": {
"$oid": "56dff56a3262d9c83eb8ab15"
},
"comment": "Varnish Customs Statistics key definitions",
"content": "#Varnish Customs Statistics key definitions \nsub vcl_deliver {\n # This creates a grouping for each specific value of the Host request header\n std.log(\"vcs-key: \" + req.http.host);\n\n # This creates a key based on both the Host header and the URL\n std.log(\"vcs-key: \" + req.http.host + req.url);\n\n # This will create two keys 'MISS' and 'HIT', each counting\n # stats for requests matching one of the two conditions.\n if (obj.hits == 0) {\n std.log(\"vcs-key: MISS\");\n }\n else {\n std.log(\"vcs-key: HIT\");\n }\n}\n",
"created": {
"$date": "2017-10-17T15:35:05.865Z"
},
"name": "VCS example",
"timestamp": {
"$date": "2017-10-17T15:35:05.865Z"
},
"version": "all"
}
{
"_id": {
"$oid": "56dff56a3262d9c83eb8ab15"
},
"comment": "Varnish Customs Statistics key definitions",
"content": "#Varnish Customs Statistics key definitions \nsub vcl_deliver {\n # This creates a grouping for each specific value of the Host request header\n std.log(\"vcs-key: \" + req.http.host);\n\n # This creates a key based on both the Host header and the URL\n std.log(\"vcs-key: \" + req.http.host + req.url);\n\n # This will create two keys 'MISS' and 'HIT', each counting\n # stats for requests matching one of the two conditions.\n if (obj.hits == 0) {\n std.log(\"vcs-key: MISS\");\n }\n else {\n std.log(\"vcs-key: HIT\");\n }\n}\n",
"created": {
"$date": "2017-10-18T09:33:58.287Z"
},
"name": "VCS example",
"timestamp": {
"$date": "2017-10-18T09:33:58.287Z"
},
"version": "all"
}
"list": [
{
"_id": {
"$oid": "55715ab309643d5a6c910522"
},
"comment": "Template VCL for virtual hosts",
"content": "# Description: Saint mode lets you filter out unwanted responses\n # your backend. Varnish will retry the request towards another backend\n # or serve from cache if there are no more available backends.\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend b1 {\n .host = \"b1.example.com\";\n .port = \"80\";\n}\nbackend b2 {\n .host = \"b1.example.com\";\n .port = \"80\";\n}\n\nsub vcl_recv { \n if (req.http.host ~ \"(?i)localhost\") { set req.backend_hint = default; }\n elseif (req.http.host ~ \"(?i)(www.|)example2.com\") { set req.backend_hint = b1; }\n elseif (req.http.host ~ \"(?i)(www.|)example3.com\") { set req.backend_hint = b2; }\n\n # vhost not defined, present an error page.\n if (req.backend_hint == default) { return (synth(750, \"OK\")); }\n}\n\nsub vcl_synth { \n if (resp.status == 750) { \n set resp.http.Content-Type = \"text/html; charset=utf-8\";\n set resp.status = 503;\n synthetic {\"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n <html><head><title>No such virtual host</title></head> <body>\n <h1>503 Service Unavailable</h1><p>There is no such virtual host defined</p></body></html>\"};\n return (deliver);\n }\n}\n\n",
"created": {
"$date": "2017-10-18T09:30:37.935Z"
},
"name": "Virtual host template_V4",
"timestamp": {
"$date": "2017-10-18T09:30:37.935Z"
},
"version": "4"
},
{
"_id": {
"$oid": "55715ab309643d5a6c910523"
},
"comment": "How to do filtering in Varnish on Set-Cookie header",
"content": "# Description: How to do filtering in Varnish on Set-Cookie header\n# when there are more of them present\n# Source: https://github.com/varnish/libvmod-header\nimport header;\nheader.remove(beresp.http.Set-Cookie,\"dontneedthiscookie\");\n",
"created": {
"$date": "2017-10-18T09:30:37.935Z"
},
"name": "multiple-set-cookie",
"timestamp": {
"$date": "2017-10-18T09:30:37.935Z"
},
"version": "all"
},
{
"_id": {
"$oid": "56dff56a3262d9c83eb8ab15"
},
"comment": "Varnish Customs Statistics key definitions",
"content": "#Varnish Customs Statistics key definitions \nsub vcl_deliver {\n # This creates a grouping for each specific value of the Host request header\n std.log(\"vcs-key: \" + req.http.host);\n\n # This creates a key based on both the Host header and the URL\n std.log(\"vcs-key: \" + req.http.host + req.url);\n\n # This will create two keys 'MISS' and 'HIT', each counting\n # stats for requests matching one of the two conditions.\n if (obj.hits == 0) {\n std.log(\"vcs-key: MISS\");\n }\n else {\n std.log(\"vcs-key: HIT\");\n }\n}\n",
"created": {
"$date": "2017-10-18T09:30:37.935Z"
},
"name": "VCS example",
"timestamp": {
"$date": "2017-10-18T09:30:37.935Z"
},
"version": "all"
},
{
"_id": {
"$oid": "597eda0358e6d473b771f66c"
},
"comment": "A very basic skeleton to get you started.",
"content": "# A basic skeleton.\nvcl 4.0;\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n}",
"created": {
"$date": "2017-10-18T09:30:37.935Z"
},
"name": "A skeleton.",
"timestamp": {
"$date": "2017-10-18T09:30:37.935Z"
},
"version": "4"
}
]
}
/api/v1/snippet/1/2
{page_number}=1
{items_per_page}=2
{
"list": [
{
"_id": {
"$oid": "55715ab309643d5a6c910511"
},
"comment": "Saint mode lets you filter out unwanted responses from",
"content": "# Description: Saint mode lets you filter out unwanted responses from\n# your backend. Varnish will retry the request towards another backend\n# or serve from cache if there are no more available backends.\n\nsub vcl_recv {\n # Allow 1 hour of \"grace\", making Varnish\n # serve objects up to 1 hours past their TTL\n set req.grace = 1h;\n}\n\nsub vcl_fetch {\n if (beresp.status == 500) {\n # blacklist the object from this backend \n # for 20 seconds:\n set beresp.saintmode = 20s;\n\n if (req.request != \"POST\") {\n # restart the transaction unless it is a POST\n return(restart);\n } else {\n # if it is a POST there isn't much we can do...\n error 500 \"Failed\";\n }\n }\n set beresp.grace = 1h;\n}\n",
"created": {
"$date": "2013-11-10T13:00:20.261Z"
},
"name": "saint-mode",
"timestamp": {
"$date": "2013-11-10T13:00:20.282Z"
},
"version": "3"
},
{
"_id": {
"$oid": "55715ab309643d5a6c910512"
},
"comment": "Store the URL in the object to help the ban lurker.",
"content": "# Description: Store the URL in the object to help the ban lurker. \n# See https://www.varnish-cache.org/docs/trunk/tutorial/purging.html for a full description.\n\n sub vcl_fetch {\n set beresp.http.x-url = req.url;\n}\nsub vcl_deliver {\n unset resp.http.x-url; # Optional\n}\n# when adding new bans use obj.http.x-url instead of req.url.\n",
"created": {
"$date": "2013-11-10T13:00:20.273Z"
},
"name": "Lurker friendly bans",
"timestamp": {
"$date": "2013-11-10T13:00:20.282Z"
},
"version": "3"
}
]
}
{
"name" : "test",
"content" : "vcl 4.0;\n"
}
{
"_id": {
"$oid": "59e72194fbea8558092aee1a"
},
"content": "vcl 4.0;\\n",
"created": {
"$date": "2017-10-18T09:40:36.665Z"
},
"name": "test",
"timestamp": {
"$date": "2017-10-18T09:40:36.665Z"
}
}
{
"content": "vcl 4.0;\\n #Just a comment"
}
{
"_id": {
"$oid": "59e72194fbea8558092aee1a"
},
"content": "vcl 4.0;\\n #Just a comment",
"created": {
"$date": "2017-10-18T09:40:36.665Z"
},
"name": "test",
"timestamp": {
"$date": "2017-10-18T09:45:10.732Z"
}
}
{
"message": "Entity with id=59e72194fbea8558092aee1a removed successfully."
}