FIX: cache avatars in NGINX

This commit is contained in:
Sam 2014-07-15 10:30:27 +10:00
parent 1d717088c3
commit cea5350a3c
1 changed files with 19 additions and 4 deletions

View File

@ -10,6 +10,8 @@ upstream discourse {
server unix:/var/www/discourse/tmp/sockets/thin.3.sock;
}
proxy_cache_path /var/nginx/cache keys_zone=one:10m max_size=200m;
# If you are going to use Puma, use these:
#
# upstream discourse {
@ -112,10 +114,7 @@ server {
break;
}
# This big block is needed so we can selectively enable
# acceleration for backups and avatars
# see note about repetition above
location ~ ^/(backups|letter_avatar|user_avatar) {
location ~ ^/backups/ {
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;
@ -126,6 +125,22 @@ server {
break;
}
# This big block is needed so we can selectively enable
# acceleration for backups and avatars
# see note about repetition above
location ~ ^/(letter_avatar|user_avatar) {
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-Forwarded-Proto $thescheme;
# note x-accel-redirect can not be used with proxy_cache
proxy_cache one;
proxy_cache_valid any 1m;
proxy_cache_valid 200 301 302 7d;
proxy_pass http://discourse;
break;
}
# this means every file in public is tried first
try_files $uri @discourse;
}