Last active
March 13, 2020 04:01
-
-
Save kieran/402e623880839c9eb2b9f170a313817d to your computer and use it in GitHub Desktop.
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
# api - you have to run this locally | |
backend rails { | |
.host = "localhost"; | |
.port = "3000"; | |
} | |
# local version of ember app | |
backend ember_app { | |
.host = "localhost"; | |
.port = "4200"; | |
} | |
# pre-built version of the previous app, hosted on an s3 bucket or whatever | |
backend ember_app_prebuilt { | |
.host = "ember_app.development.yourdomain.com"; | |
.port = "80"; | |
} | |
# this is the "varnish routing magic" | |
sub vcl_recv { | |
# Defaults to rails | |
set req.backend = rails; | |
set req.grace = 60s; | |
set req.hash_always_miss = false; | |
# builds a "fallback director" - if the first backend is unhealthy, it will use the second | |
new ember_director = directors.fallback(); | |
ember_director.add_backend(ember_app); | |
ember_director.add_backend(ember_app_prebuilt); | |
# routes traffic based on the request | |
if(req.url ~ "^/cool-url/") { | |
# send to the embeer-cli app instead | |
set req.backend = ember_director; | |
# this tells s3 which domain you're asking for | |
set req.http.Host = "ember_app.development.yourdomain.com"; | |
# serve index.html for noon-asset requests | |
if (req.http.file_ext == "") { | |
set req.url = "/index.html"; | |
} | |
return(pass); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment