Skip to content

Instantly share code, notes, and snippets.

@jyfcrw
Last active February 13, 2017 20:12
Show Gist options
  • Save jyfcrw/d047f98cb0c9b30686c7 to your computer and use it in GitHub Desktop.
Save jyfcrw/d047f98cb0c9b30686c7 to your computer and use it in GitHub Desktop.
Nginx server configuration with X-Sendfile for Rails
server {
listen 80;
listen [::]:80;
server_name mydomian.com *.mydomian.com;
root /var/www/default/apps/myproject/current/public;
passenger_enabled on;
passenger_set_header X-Sendfile-Type "X-Accel-Redirect";
passenger_env_var HTTP_X_ACCEL_MAPPING /var/www/default/apps/myproject/shared/public/protects/=/protects/;
passenger_pass_header X-Accel-Redirect;
access_log /var/log/nginx/myproject.log;
error_log /var/log/nginx/myproject.log;
location ~ ^/(assets|uploads)/ {
gzip on;
gzip_static on;
expires max;
add_header Cache-Control public;
add_header ETag "";
}
location ~ /protects/(.*) {
internal;
alias /var/www/default/apps/myproject/shared/public/protects/$1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment