Ticket #746: nginx.patch
| File nginx.patch, 6.2 KB (added by , 11 years ago) |
|---|
-
conf.d/default.conf
From f7c4e5a1fca1ca5c158dc393a44d753b0dccc8a8 Mon Sep 17 00:00:00 2001 From: root <root@base.vagrant.foo.com> Date: Mon, 6 Apr 2015 14:00:48 -0500 Subject: [PATCH 1/2] working --- conf.d/default.conf | 59 +++++++++++++++++++++++++++++++++++++++++++++----- nginx.conf | 13 ++++++++++- 2 files changed, 65 insertions(+), 7 deletions(-) diff --git a/conf.d/default.conf b/conf.d/default.conf index 34aeb9a..8de7683 100644
a b 1 # 2 # The default server 3 # 1 4 server { 2 listen 80 ;3 server_name localhost;5 listen 80 default_server; 6 server_name _; 4 7 5 8 #charset koi8-r; 6 #access_log /var/log/nginx/log/host.access.log main; 9 10 #access_log logs/host.access.log main; 11 12 # Load configuration files for the default server block. 13 include /etc/nginx/default.d/*.conf; 14 15 proxy_cache ae_images; 7 16 8 17 location / { 9 root /usr/share/nginx/html; 10 index index.html index.htm; 18 # Won't need this with our own app 19 proxy_set_header Host pics.foo.com; 20 proxy_pass http://image_servers; 21 #proxy_pass http://pics.foo.com; 22 # These only take effect if there's no expires/cache-control from the backend 23 proxy_cache_valid 200 302 10m; 24 proxy_cache_valid 404 1m; 25 # Add or append x-forwarded-for 26 proxy_set_header X-Forwarded-Proto $scheme; 27 proxy_set_header X-Real-IP $remote_addr; 28 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 29 # For keepalive connections, turn this on if version >= 1.1.4 30 proxy_http_version 1.1; 31 32 # Only allow one request for each URI to the backend at a time, e.g. 33 # 200 clients ask for favico.ico at the same time, only one request hits the 34 # backend. 35 # Turn this on if version >= 1.1.12 36 proxy_cache_lock on; 37 # The amount of time the lock is placed in the above scenario. 38 #proxy_cache_lock_age 2s; 39 40 # Enable nginx to use if-modified-since and if-none-match to backend 41 # Turn this on if version >= 1.5.7 42 proxy_cache_revalidate on; 43 44 # Allow nginx to send potentially stale content when: 45 proxy_cache_use_stale error timeout invalid_header updating 46 http_500 http_502 http_503 http_504; 47 proxy_connect_timeout 5s; 48 # Replace backend error with our own: 49 proxy_intercept_errors on; 50 # TODO should we include 500's here? 51 proxy_next_upstream error timeout; 52 #TODO do we need to rewrite redirects with proxy_redirect? 53 11 54 } 12 55 13 #error_page 404 /404.html; 56 error_page 404 /404.html; 57 location = /404.html { 58 root /usr/share/nginx/html; 59 } 14 60 15 61 # redirect server error pages to the static page /50x.html 16 62 # … … server { 43 89 #} 44 90 } 45 91 92 -
nginx.conf
diff --git a/nginx.conf b/nginx.conf index e4bad8d..0600cc0 100644
a b http { 15 15 include /etc/nginx/mime.types; 16 16 default_type application/octet-stream; 17 17 18 upstream image_servers { 19 server pics.foo.com weight=5; 20 server mbp.foo.com down; 21 } 22 # "One megabyte zone can store about 8 thousand keys." 23 proxy_cache_path /usr/share/nginx/data/cache levels=1:2 keys_zone=ae_images:100m max_size=2G inactive=24h; 24 25 log_format proxylog '$remote_addr - $remote_user [$time_local] "$request" ' 26 '$status $body_bytes_sent "$http_referer" ' 27 '"$http_user_agent" "$http_x_forwarded_for" $upstream_addr $upstream_response_time'; 28 18 29 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 19 30 '$status $body_bytes_sent "$http_referer" ' 20 31 '"$http_user_agent" "$http_x_forwarded_for"'; 21 32 22 access_log /var/log/nginx/access.log main;33 access_log /var/log/nginx/access.log proxylog; 23 34 24 35 sendfile on; 25 36 #tcp_nopush on; -
conf.d/default.conf
-- 1.7.1 From ac2de3f7ee9c1868e8695102300ead1858b01e25 Mon Sep 17 00:00:00 2001 From: root <root@base.vagrant.foo.com> Date: Thu, 9 Apr 2015 10:06:09 -0500 Subject: [PATCH 2/2] remove revalidation to test --- conf.d/default.conf | 9 ++++++++- nginx.conf | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/conf.d/default.conf b/conf.d/default.conf index 8de7683..82a084b 100644
a b server { 26 26 proxy_set_header X-Forwarded-Proto $scheme; 27 27 proxy_set_header X-Real-IP $remote_addr; 28 28 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 29 # Add diagnostic header 30 add_header X-Cache-Status $upstream_cache_status; 29 31 # For keepalive connections, turn this on if version >= 1.1.4 30 32 proxy_http_version 1.1; 31 33 … … server { 39 41 40 42 # Enable nginx to use if-modified-since and if-none-match to backend 41 43 # Turn this on if version >= 1.5.7 42 proxy_cache_revalidate on; 44 # 45 # Turning this on comes with a warning, the revalidation doesn't update the expires 46 # headers on the cached item. Rather, it holds the object as valid until the 47 # invalid_time on the store expires before it revalidates again. Turning this on 48 # coupled with a high inactive time could result in serving up stale data. 49 # proxy_cache_revalidate on; 43 50 44 51 # Allow nginx to send potentially stale content when: 45 52 proxy_cache_use_stale error timeout invalid_header updating -
nginx.conf
diff --git a/nginx.conf b/nginx.conf index 0600cc0..cefc626 100644
a b events { 14 14 http { 15 15 include /etc/nginx/mime.types; 16 16 default_type application/octet-stream; 17 server_tokens off; 18 17 19 18 20 upstream image_servers { 19 21 server pics.foo.com weight=5; … … http { 24 26 25 27 log_format proxylog '$remote_addr - $remote_user [$time_local] "$request" ' 26 28 '$status $body_bytes_sent "$http_referer" ' 27 '"$http_user_agent" "$http_x_forwarded_for" $upstream_addr $upstream_response_time ';29 '"$http_user_agent" "$http_x_forwarded_for" $upstream_addr $upstream_response_time $upstream_cache_status'; 28 30 29 31 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 30 32 '$status $body_bytes_sent "$http_referer" '
