Skip to content

Instantly share code, notes, and snippets.

@cuibonobo
Forked from shilman/sidebar
Created July 10, 2016 21:48
Show Gist options
  • Save cuibonobo/b37981e0c4fa27a75b786d3c713ed4e2 to your computer and use it in GitHub Desktop.
Save cuibonobo/b37981e0c4fa27a75b786d3c713ed4e2 to your computer and use it in GitHub Desktop.
proxy_cache_path /var/cache/nginx/sidebar levels=1:2 keys_zone=SIDEBAR:10m inactive=24h max_size=1g;
upstream sidebar {
ip_hash;
server xxx.xxx.xx.xxx:80;
server yyy.yyy.yy.yyy:80;
}
server {
listen 0.0.0.0:80;
server_name sidebar.io;
access_log /var/log/nginx/sidebar.access;
set $skip_cache 0;
location / {
# PROXY STARTS HERE ========
proxy_pass http://sidebar/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto http;
proxy_set_header X-Nginx-Proxy true;
proxy_redirect off;
# CACHING STARTS HERE ========
if ($cookie_meteor_login_token) {
set $skip_cache 1;
}
proxy_cache_bypass $skip_cache;
proxy_no_cache $skip_cache;
proxy_cache SIDEBAR;
proxy_cache_valid 200 30s;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
proxy_ignore_headers "Cache-Control" "Expires";
add_header X-Cached $upstream_cache_status;
}
}
@elie222
Copy link

elie222 commented Oct 14, 2016

Why do you do this:
proxy_ignore_headers "Cache-Control" "Expires";?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment