upstream alaveteli { server 127.0.0.1:3300; } server { listen 80; root /var/www/alaveteli/alaveteli/public; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto http; proxy_redirect off; try_files $uri @ruby; } location /download { internal; alias /var/www/alaveteli/alaveteli/cache/zips/development/download; } location @ruby { proxy_pass http://alaveteli; proxy_set_header Host $http_host; proxy_set_header X-Sendfile-Type X-Accel-Redirect; proxy_set_header X-Accel-Mapping /var/www/alaveteli/alaveteli/cache/zips/development/download=/download; } }