FIX: properly support sendfile on all routes
FIX: disable unused etags
This commit is contained in:
parent
95282a4c6d
commit
103e2ebba9
|
@ -117,6 +117,11 @@ module Discourse
|
||||||
# for some reason still seeing it in Rails 4
|
# for some reason still seeing it in Rails 4
|
||||||
config.middleware.delete Rack::Lock
|
config.middleware.delete Rack::Lock
|
||||||
|
|
||||||
|
# ETags are pointless, we are dynamically compressing
|
||||||
|
# so nginx strips etags, may revisit when mainline nginx
|
||||||
|
# supports etags (post 1.7)
|
||||||
|
config.middleware.delete Rack::ETag
|
||||||
|
|
||||||
# route all exceptions via our router
|
# route all exceptions via our router
|
||||||
config.exceptions_app = self.routes
|
config.exceptions_app = self.routes
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,14 @@ server {
|
||||||
# (This will also prevent compatibility mode in IE 8 and 9, but those browsers aren't supported anyway.
|
# (This will also prevent compatibility mode in IE 8 and 9, but those browsers aren't supported anyway.
|
||||||
add_header X-UA-Compatible "IE=edge";
|
add_header X-UA-Compatible "IE=edge";
|
||||||
|
|
||||||
|
# without weak etags we get zero benefit from etags on dynamically compressed content
|
||||||
|
# further more etags are based on the file in nginx not sha of data
|
||||||
|
# use dates, it solves the problem fine even cross server
|
||||||
|
etag off;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
root $public;
|
root $public;
|
||||||
|
add_header ETag "";
|
||||||
|
|
||||||
location ~* \.(eot|ttf|woff|ico)$ {
|
location ~* \.(eot|ttf|woff|ico)$ {
|
||||||
expires 1y;
|
expires 1y;
|
||||||
|
@ -62,15 +68,14 @@ server {
|
||||||
|
|
||||||
location ~ ^/assets/ {
|
location ~ ^/assets/ {
|
||||||
expires 1y;
|
expires 1y;
|
||||||
|
# asset pipeline enables this
|
||||||
gzip_static on;
|
gzip_static on;
|
||||||
add_header ETag "";
|
|
||||||
add_header Cache-Control public;
|
add_header Cache-Control public;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ ^/uploads/ {
|
location ~ ^/uploads/ {
|
||||||
expires 1y;
|
expires 1y;
|
||||||
add_header ETag "";
|
|
||||||
add_header Cache-Control public;
|
add_header Cache-Control public;
|
||||||
|
|
||||||
## optional upload anti-hotlinking rules
|
## optional upload anti-hotlinking rules
|
||||||
|
@ -90,25 +95,11 @@ server {
|
||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
}
|
}
|
||||||
|
|
||||||
# attachments must go through the rails application to get the right content-disposition header
|
|
||||||
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;
|
|
||||||
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
|
|
||||||
proxy_set_header X-Accel-Mapping $public/=/downloads/;
|
|
||||||
proxy_pass http://discourse;
|
proxy_pass http://discourse;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ ^/backups/ {
|
location ~ ^/backups/ {
|
||||||
# backups must go through the rails application to handle security
|
|
||||||
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;
|
|
||||||
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
|
|
||||||
proxy_set_header X-Accel-Mapping $public/=/downloads/;
|
|
||||||
proxy_pass http://discourse;
|
proxy_pass http://discourse;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -126,6 +117,9 @@ server {
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $thescheme;
|
proxy_set_header X-Forwarded-Proto $thescheme;
|
||||||
|
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
|
||||||
|
# required at parent level as various routes take advantage
|
||||||
|
proxy_set_header X-Accel-Mapping $public/=/downloads/;
|
||||||
proxy_pass http://discourse;
|
proxy_pass http://discourse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue