diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/etc/varnish/nms.vcl | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/web/etc/varnish/nms.vcl b/web/etc/varnish/nms.vcl new file mode 100644 index 0000000..5f262a6 --- /dev/null +++ b/web/etc/varnish/nms.vcl @@ -0,0 +1,74 @@ +# +# This is an example VCL file for Varnish. +# +# It does not do anything by default, delegating control to the +# builtin VCL. The builtin VCL is called when there is no explicit +# return statement. +# +# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/ +# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples. + +# Marker to tell the VCL compiler that this VCL has been adapted to the +# new 4.0 format. +vcl 4.0; + +# Default backend definition. Set this to point to your content server. +backend default { + .host = "127.0.0.1"; + .port = "8080"; +} + +sub vcl_recv { + + if (req.method != "GET" && + req.method != "HEAD" && + req.method != "PUT" && + req.method != "POST" && + req.method != "TRACE" && + req.method != "OPTIONS" && + req.method != "DELETE") { + /* Non-RFC2616 or CONNECT which is weird. */ + return (pipe); + } + + # Hardcoded for testing + set req.http.host = "nms.tg16.gathering.org"; + + if (req.method != "GET" && req.method != "HEAD") { + /* We only deal with GET and HEAD by default */ + return (pass); + } + + unset req.http.Cookie; + + return (hash); + } + +sub vcl_hash { + hash_data(req.http.authorization); +} + +sub vcl_backend_response { + # Happens after we have read the response headers from the backend. + # + # Here you clean the response headers, removing silly Set-Cookie headers + # and other mistakes your backend does. + if (!(bereq.http.host ~ "stream")) { + if (beresp.status == 200) { + set beresp.ttl = 2s; + } else { + set beresp.ttl = 0s; + } + if(bereq.url ~ "port-state.pl" && beresp.status == 200) { + set beresp.ttl = 1s; + } + if (beresp.status == 200 && bereq.url ~ "now=") { + set beresp.ttl = 60m; + } + if (beresp.status == 500) { + return (retry); + } + } + +} + |