Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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