Skip to content

Instantly share code, notes, and snippets.

@DavidWittman
Created June 1, 2012 19:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidWittman/2854721 to your computer and use it in GitHub Desktop.
Save DavidWittman/2854721 to your computer and use it in GitHub Desktop.
Varnish VCL to detect and redirect file uploads
backend default {
.host = "127.0.0.1";
.port = "8080";
}
backend master {
.host = "10.x.x.x";
.port = "80";
}
sub vcl_recv {
# Any uploads or restarts should go to the master backend
if (req.restarts > 0 ||
req.http.Content-Type ~ "multipart/form-data") {
set req.backend = master;
}
}
sub vcl_fetch {
# Restart requests which weren't found here
if (beresp.status == 404 && req.restarts == 0) {
return(restart);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment