title: Adding custom HTTP headers to nginx X-Accel-Redirect
body: <p>I am serving restricted downloads in rails using <code>X-Accel-Redirect</code> with nginx. To validate my downloads in client app, i am trying to send the checksum in the non standard HTTP header <code>Content-MD5</code> to the <code>X-Accel-Redirect</code> request. But this is not working.</p>
  
  <p>below the rails snippet used to do the redirection</p>
  
  <pre><code>headers['X-Accel-Redirect'] = '/download_public/uploads/stories/' + params[:story_id] +'/' + params[:story_id] + '.zip'
              headers['X-Accel-Expires'] = 'max'
              checksum = Digest::MD5.file(Rails.root.dirname.to_s+'/public/uploads/stories/' + params[:story_id] +'/' + params[:story_id] + '.zip').hexdigest
              headers['Content-MD5'] = checksum
              request.session_options[:skip] = true
              render :nothing =&gt; true, :content_type =&gt; MIME::Types.type_for('.zip').first.content_type
  </code></pre>
  
  <p>This is the nginx section</p>
  
  <pre><code>location /download_public { 
   internal;
   proxy_pass_header Content-MD5;
   add_header Cache-Control "public, max-age=315360000";
   add_header Content-Disposition "inline"; 
   alias /var/www/sss/public; 
  }
  </code></pre>
  
  <p>This is not working apparently. I am not able to get the Content-MD5 header in my responses. Is there any way to pass my Content-MD5 header from rails?</p>
  
  <p>I know there are ways to do that entirely in nginx, like compiling nginx with perl or lua and easily calculate the MD5 on the fly. But i dont want to do that. </p>
  
  <p>Any help is much appreciated.</p>