Created
October 10, 2012 06:41
-
-
Save klaasvw/3863541 to your computer and use it in GitHub Desktop.
Set up Varnish to proxy to a different host
This file contains 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
# Add this code to your VCL configuration. | |
# | |
# I assume a default backend has already been configured. | |
# If different from the default backend, add one for the host to proxy to. Note that these | |
# values are just examples. | |
backend proxy_host { | |
.host = "proxy_host.dev"; | |
.port = "8080"; | |
} | |
# This is where the magic happens. We detect an incoming request and proxy it to the other | |
# host. | |
# Note that is a very bare bones setup, purely for illustrating you to proxy. | |
sub vcl_recv { | |
if (req.http.host ~ "^incoming_host\.dev") { | |
set req.http.X-Forwarded-Host = req.http.host; | |
set req.http.host = "proxy_host.dev"; | |
set req.backend = proxy_host; | |
} | |
return (pass); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment