ximus
ximus

Reputation: 395

Advice request: Serve local folder through rails (or not?)

The task: Serve the files located in a local folder on the server to clients over http/80. In the end, I plan to emulate the folder on the client but that doesn't concern my question.

So, there is an existing Rails app (rest based/xml) on that server that the clients would use in conjunction with these files.

I don't need any logic to be done on the files either on upload or download so I ask myself:

  1. Do I need to involve my Rails app in serving these files?
  2. Shouldn't the webserver solely handle the link between the local files and the clients?
  3. Would this new Rails Metal or Rack integration be part of the solution? (not familiar with either)

I guess the important thing here is http over port 80.

Thanks for any pointers or advice on the matter, cheers, Max

I know that with the good time investment I could look all this up for a couple of hours and figure it out but I am very very busy saves me alot of time.

Upvotes: 1

Views: 318

Answers (3)

Steve Madsen
Steve Madsen

Reputation: 13791

Apache? Just add another <Directory> section to your configuration for the Rails app:

Alias /static-files /path/to/the/static-files
<Directory /path/to/the/static-files>
    Order allow, deny
    Allow from all
    # whatever else you need, Options, AllowOverride, etc.
</Directory>

Upvotes: 1

Kevin
Kevin

Reputation: 485

you can use X-Sendfile if you are using Apache or Lighty (see this blog post). Nginx supports X-Accel-Redirect. Both of these approaches will let your web server directly send the file without involving your rails app.

Upvotes: 0

Noel Walters
Noel Walters

Reputation: 1853

Put the files in a subdirectory of the "public" directory - as with stylesheets and javascripts

Upvotes: 0

Related Questions