Skip to content

Instantly share code, notes, and snippets.

@bolstad
Created April 19, 2013 18:45
Show Gist options
  • Save bolstad/5422344 to your computer and use it in GitHub Desktop.
Save bolstad/5422344 to your computer and use it in GitHub Desktop.
# Origin pull in nginx
# Origin pull in nginx
upstream origin {
server host.domain.tld:80;
}
server {
listen 80;
root /var/www;
index index.html index.htm;
server_name otherhost.domain.tld;
location / {
# configuration for web root
}
# This is the location that has a origin pull mechanism
location /static {
# In this example we servce some static files
# First check if the file is available localy
# if not, go to the redirect location
try_files $uri @redirect;
}
location @redirect {
# First make sure the machine itself has a resolver
# Since you can only have one ip here
resolver 127.0.0.1;
# This is where the origin file is
proxy_pass http://origin$uri;
# this is the uri localy
# Make sure that /var/www/static is created
# and that the user running the server is allowed
# to write there.
proxy_store /var/www$uri;
# The permissions of the created files.
proxy_store_access user:rw group:rw all:r;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment