diff --git a/config/nginx.sample.conf b/config/nginx.sample.conf index 4b56e39cec0..bda6022ca08 100644 --- a/config/nginx.sample.conf +++ b/config/nginx.sample.conf @@ -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; }