Questions tagged [fastly-vcl]

12 questions
2
votes
3 answers

Accessing the body of the backend response in Varnish VCL

My Varnish VCL code needs to make a simple GET request into a backend system and decide if the requested resource is accessible or not. Unfortunately, the backend system always returns 200, and I must examine the actual body of the response to…
Yuri Astrakhan
  • 8,808
  • 6
  • 63
  • 97
1
vote
1 answer

Obtain error cause inside Fastly vcl_error subroutine

Fastly allows to customise vcl_error subroutine. However, If I override it (e.g. sub vcl_error { #FASTLY error set obj.http.Custom-Header = "foo-bar"; return(deliver); } ), original response body with error cause (e.g. "first byte timout") is…
Sergey Galkin
  • 159
  • 3
  • 8
1
vote
1 answer

VCL return(lookup)

We are using Fastly and its Varnish to deliver content from our services. To distribute the content amongst several services, we are using following snippet: sub vcl_recv { #FASTLY recv if (req.url.path ~ "^/services/") { set…
Vojtěch
  • 11,312
  • 31
  • 103
  • 173
1
vote
1 answer

How to extract first n characters of a string in varnish-vcl?

I'm looking for a way to extract the first 'n' characters from a string in VCL. I couldn't find any function like trim(str,starting_pos) or substring(str,len) in the VCL documentation. I've tried searching for this on google and stackoverflow and…
trogdor
  • 13
  • 4
1
vote
1 answer

Fastly vcl for 301 redirecting mixed case paths to lowercase

Since a migration, my app has mixed case paths that are still linked to, but these should 301 redirect to all lowercase paths. However there are some paths that need to still exist as mixed case for legacy api and graphql query reasons. A more…
jerome
  • 4,809
  • 13
  • 53
  • 70
0
votes
1 answer

extract string from req.url.path in VCL Fastly

I need help to extract values from string req.url.path which looks like this: /a/b/c/d Need to extract c, if there is url, like /a, it should return ''. I tried regsub(req.url.path, "/a/b/", "\5"); Tried with replace too. but it is not effectively…
pl2ern4
  • 340
  • 2
  • 10
0
votes
1 answer

Push http2 all CSS asset files using Varnish regex

I'm using Varnish (fastly) and http2 to push css and js files. I want to push all css, js, png files. My current configuration pushes only specified files from a given path: if (fastly_info.is_h2 && req.url ~ "pl_PL") { …
Łukasz D. Tulikowski
  • 1,440
  • 1
  • 17
  • 36
0
votes
1 answer

Alternative to 'ban' for Varnish 2.x

We are using below code in Varnish 4.x: if (req.http.X-Pool) { ban("obj.http.X-Pool ~ " + req.http.X-Pool); } Now we are moving to Fastly which uses Varnish 2.x, so we are not getting what is the alternative to ban in Varnish 2.x
0
votes
1 answer

Fastly: Route n% of traffic based on a path param

Have an interesting task when I don't want to have a full rollout of a new feature. I'd like to route only the percentage of traffic (based on a path parameter) to the new endpoint. I'd like to calculate the percentage based on a…
Zefr
  • 11
  • 2
0
votes
1 answer

Putting dynamic CSS URLs in HTTP headers with Fastly CDN

I'm generating dynamic CSS URLs for cache-busting. I.e. they're in the format styles-thisisthecontenthash123.css. I also want to use HTTP Link headers to load the files slightly faster. I.e. have the header Link:…
Leo Jiang
  • 24,497
  • 49
  • 154
  • 284
0
votes
1 answer

How to fix unterminated short string error in Varnish VCL while configuring Fastly CDN

I am trying to setup token based authentication on Fastly CDN with Varnish VCL and using this sample VCL snippet to generate and validate JWT tokens here - sub vcl_recv { #FASTLY recv if (req.request != "HEAD" && req.request != "GET" &&…
Harshit Laddha
  • 2,044
  • 8
  • 34
  • 64
0
votes
1 answer

fastly and/or general varnish subroutine request flow

So Fastly use a modified version of varnish 2.1.5 They don't provide diagrams of the subroutine request flow, but varnish do (see below). Now according to the below image vcl_hash is only ever entered when you execute a lookup within vcl_recv. But…
Integralist
  • 5,899
  • 5
  • 25
  • 42