Created
June 18, 2017 01:09
-
-
Save 64lines/87623a87d1409a9f3a4bc6f77a641914 to your computer and use it in GitHub Desktop.
GNINX - Configuration
This file contains hidden or 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
| 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; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment