Skip to content

Instantly share code, notes, and snippets.

@cantremember
Created March 23, 2012 05:18
Show Gist options
  • Save cantremember/2167164 to your computer and use it in GitHub Desktop.
Save cantremember/2167164 to your computer and use it in GitHub Desktop.
Facebook Tunneling with nginx example conf
#
# included into vhosts/localhost.conf (*.by-ip)
# answers to :80
#
# registered with FaceBook
location /forgiveness {
# no-trailing-/ case (the rewritten URI has a zero length)
if ($request_filename = '') {
rewrite (.*) $1/;
}
# the only way i could figure to get conditional proxying
# proxy_pass via variables = no
# if { proxy_pass } = no
# so ... two more goofy contexts
# magic tunnel cookie (any value)
if ($http_cookie ~ '_forgiveness_tunnel=1') {
# last : stop rewriting, but re-process through nginx (vs. break)
rewrite /forgiveness(.*) /forgiveness-dev$1 last;
}
rewrite /forgiveness(.*) /forgiveness-pub$1;
}
location /forgiveness-pub {
# root contextify
# break to terminate re-processing through nginx
rewrite /forgiveness-pub(.*) $1 break;
proxy_pass http://cantremember_forgiveness_cluster;
}
location /forgiveness-dev {
rewrite /forgiveness-dev(.*) $1 break;
# same as public upstream
proxy_pass http://127.0.0.1:3100;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment