~justin-fathomdb/charms/trusty/wordpress/trunk

« back to all changes in this revision

Viewing changes to files/charm/nginx/etc_nginx_sites-enabled_loadbalancer

  • Committer: Marco Ceppi
  • Date: 2012-08-24 01:14:11 UTC
  • mfrom: (51.1.100 wordpress)
  • Revision ID: marco@ceppi.net-20120824011411-mvtjdhxfl0gq48rr
* Nginx as a webserver
* Allow for scale-out with nginx
* Track Themes, Plugins, and other custom files in remote repo
* Cache levels are user-definable
* Share files between nodes with NFS
* Lots of performance enhancements

# Todo
* Add memcache support
* Wider support for remote files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Default before peer relation is handled
 
2
proxy_cache_path /mnt/ramdisk/proxy-cache levels=1:2 keys_zone=proxycache:5m max_size=1000m;
 
3
 
 
4
upstream backend {
 
5
  server 127.0.0.1:8080;
 
6
}
 
7
 
 
8
server {
 
9
  listen 80 default;
 
10
  server_name _;
 
11
  location / {
 
12
    set $no_cache "";
 
13
 
 
14
    if ($request_method !~ ^(GET|HEAD)$) {
 
15
      set $no_cache "1";
 
16
    }
 
17
 
 
18
    if ($no_cache = "1") {
 
19
      add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
 
20
      add_header X-Microcachable "0";
 
21
    }
 
22
 
 
23
    if ($http_cookie ~* "_mcnc") {
 
24
      set $no_cache "1";
 
25
    }
 
26
 
 
27
    proxy_no_cache $no_cache;
 
28
    proxy_cache_bypass $no_cache;
 
29
 
 
30
    proxy_redirect   http://backend  /;
 
31
    proxy_pass  http://backend;
 
32
    proxy_cache proxycache;
 
33
    proxy_cache_key $scheme$host$request_method$request_uri;
 
34
    proxy_cache_valid 200 60s;
 
35
    proxy_cache_use_stale updating;
 
36
 
 
37
    proxy_set_header Host $host;
 
38
    proxy_set_header X-Real-IP $remote_addr;
 
39
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 
40
 
 
41
    proxy_max_temp_file_size 1M;
 
42
 
 
43
    # Custom logging
 
44
    log_format custom '$remote_addr - $remote_user [$time_local]  '
 
45
             '"$request" $status $body_bytes_sent '
 
46
             '"$http_referer" "$http_user_agent" nocache:$no_cache';
 
47
    access_log  /mnt/logs/microcache.log custom;
 
48
 
 
49
  }
 
50
}
 
51