Created
June 1, 2012 19:46
-
-
Save DavidWittman/2854721 to your computer and use it in GitHub Desktop.
Varnish VCL to detect and redirect file uploads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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