Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
What is rails3_disable_x_sendfile?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Trevor Turk  
View profile  
 More options Mar 21 2011, 7:20 am
From: Trevor Turk <trevort...@gmail.com>
Date: Mon, 21 Mar 2011 04:20:50 -0700 (PDT)
Local: Mon, Mar 21 2011 7:20 am
Subject: What is rails3_disable_x_sendfile?

I'm seeing the following when pushing to Heroku:

Configure Rails 3 to disable x-sendfile
Installing rails3_disable_x_sendfile... done

What is this about? Is there a way I should configure my app to avoid seeing
this message?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Keenan Brock  
View profile  
 More options Mar 21 2011, 7:38 am
From: Keenan Brock <kee...@thebrocks.net>
Date: Mon, 21 Mar 2011 07:38:12 -0400
Local: Mon, Mar 21 2011 7:38 am
Subject: Re: What is rails3_disable_x_sendfile?

Hi Trevor,

config/environments/production.rb line 12

  # Specifies the header that your server uses for sending files
  # config.action_dispatch.x_sendfile_header = "X-Sendfile"

  # For nginx:
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'

  # If you have no front-end server that supports something like X-Sendfile,
  # just comment this out and Rails will serve the files

And while you are in there,
you may want to tweak

config.serve_static_assets = true

Best of luck,
Keenan

On Mar 21, 2011, at 7:20 AM, Trevor Turk wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Trevor Turk  
View profile  
 More options Mar 21 2011, 7:45 am
From: Trevor Turk <trevort...@gmail.com>
Date: Mon, 21 Mar 2011 04:45:46 -0700 (PDT)
Local: Mon, Mar 21 2011 7:45 am
Subject: Re: What is rails3_disable_x_sendfile?

I have:

config.serve_static_assets = true

...but I don't have anything with:

config.action_dispatch.x_sendfile_header

...at all. Perhaps you are doing something unnecessarily in my case? You can
view my app "teamlab" yourself on Heroku if you like. I can file a support
ticket if necessarily.

Also, you didn't answer my first question: "what is this about" ? :)

Thanks,
- Trevor


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Keenan Brock  
View profile  
 More options Mar 21 2011, 8:06 am
From: Keenan Brock <kee...@thebrocks.net>
Date: Mon, 21 Mar 2011 08:06:35 -0400
Local: Mon, Mar 21 2011 8:06 am
Subject: Re: What is rails3_disable_x_sendfile?
Hello Trevor,

Web servers (e.g.: Apache) is tuned for serving up static files.
Ruby (e.g.: mongrel) is not as efficient at serving up static files.

But sometimes, your ruby code generates a file that needs to be streamed. Or it uses logic to determine the name of an existing file that needs to be streamed.

So there is a mechanism for ruby to set a header (X-sendfile), asking apache to stream the file for it.

This is nice:
a) A mongrel is not held up
b) c code can stream a file better than ruby.
c) web servers are often tuned to use OS level calls, zero copy streaming, and stuff. Have them maintain that configuration.

I think lighttpd introduced the flag, but I digress.

You run into a problem when the static file is not on the filesystem of the apache server.
E.g.: Apache is on one server and a mongrel is running on a separate machine.

So you need to tell rails to not use the handy X-sendfile header and stream the file through.

How this affects Heroku?

The web server is running on a different machine than the dynos. So X-sendfile doesn't work.
So they modify your environments/production.rb to disable that feature.

But this tweaking takes a few seconds during slug generation, and they are tweaking your configuration. So they give you a warning to let you know.

At least, that is my take,
Keenan

On Mar 21, 2011, at 7:45 AM, Trevor Turk wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Trevor Turk  
View profile  
 More options Mar 21 2011, 9:59 am
From: Trevor Turk <trevort...@gmail.com>
Date: Mon, 21 Mar 2011 06:59:09 -0700 (PDT)
Local: Mon, Mar 21 2011 9:59 am
Subject: Re: What is rails3_disable_x_sendfile?

On Monday, March 21, 2011 12:06:35 PM UTC, Keenan wrote:

> So you need to tell rails to not use the handy X-sendfile header and stream
> the file through.

> How this affects Heroku?

> The web server is running on a different machine than the dynos. So
> X-sendfile doesn't work.
> So they modify your environments/production.rb to disable that feature.

> But this tweaking takes a few seconds during slug generation, and they are
> tweaking your configuration. So they give you a warning to let you know.

Thanks for the explanation, Keenan. Sorry, I thought you worked for Heroku!
:)

I'll follow up with Heroku directly about it.

- Trevor


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
logicaltext  
View profile  
 More options Mar 22 2011, 10:44 am
From: logicaltext <logicalt...@logicaltext.com>
Date: Tue, 22 Mar 2011 07:44:25 -0700 (PDT)
Local: Tues, Mar 22 2011 10:44 am
Subject: Re: What is rails3_disable_x_sendfile?
Hi Trevor,

Keenan is right in that Heroku doesn't support the X-sendfile method:

- http://devcenter.heroku.com/articles/rack-sendfile

The support team initially added this documentation last year after I
submitted an issue regarding problems I was having serving Sass-
generated files from `./tmp` using Rack::Static. The relevant part of
my Rails configuration looked like this:

    Sass::Plugin.options[:template_location] = {
    "#{Rails.root}/app/stylesheets" => "#{Rails.root}/tmp/stylesheets"
    }

    Rails.configuration.middleware.insert_after 'Sass::Plugin::Rack',
      'Rack::Static', :urls => ['/stylesheets'], :root =>
"#{Rails.root}/tmp"

This worked in a simple Rack app, but not in Rails--I kept getting a
503 error. A member of the Heroku support team suggested that I remove
Rack::Sendfile from my middleware stack, and that solved the issue.
Since Rack::Static delegates to Rack::File, Rack::Sendfile will add
the `X-Sendfile` header. And since Heroku doesn't support the use of
Rack::Sendfile, file downloads will fail.

When I first found about this, I just removed Rack::Sendfile from my
middleware stack, but it seems Heroku is now getting round this
automatically by configuring Rails to disable the `X-Sendfile` header.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »