Welcome! Log In Create A New Profile

Advanced

Re: Rails XSendfile via Nginx

Jonathan Matthews
May 09, 2012 06:22AM
On 9 May 2012 03:58, Ari King <lists@ruby-forum.com> wrote:
> Prior to asking my original question, I checked my error.log and found
> no errors whatsoever. I also tried using curl, but the content returned
> is a Nginx 404 error page. Any other ideas? I also doubled checked my
> alias configuration; as per nginx docs, location & alias take regex
> expressions and captures. My hunch is that the url is the problem
> (/recipes/1/video) since it does NOT contain the filename.

Yes, that's what I meant about your use of "alias" being screwy. You
haven't indicated that you've tried hitting the app *directly*,
without nginx in the way, and examining the headers. This is always
really useful. In this case, however, I think the fault lies
elsewhere.

Here's what you've got in your config:
------------------------
location /recipes/(.*)/video {
alias /var/www/app/current/uploads/videos/$1/original/;
}
------------------------

To me, this looks like when you request

http://foo.bar.com/recipes/123/video

you're asking nginx to serve the "file"

/var/www/app/current/uploads/videos/123/original/

But this isn't a file, it's a directory. So
http://wiki.nginx.org/HttpIndexModule#index kicks in and (unless
you've changed it) tries to serve
/var/www/app/current/uploads/videos/123/original/index.html.
Hence the 404.

I think your taxonomy is a bit fucked here, TBH, and you're reaping
the rewards of trying to implement the wrong public-facing data
structure.
If you have the scope to change it, I'd be going with something where
(a) "video" is on the left of the video ID and possibly (b) where
/recipes/ is out of the picture all together. Something like

http://foo.bar.com/video/123 or, if you anticipate getting to any scale
http://foo.bar.com/video/000/1/123 or, if "recipe" is still important
http://foo.bar.com/video/recipes/123 to allow you to have non-recipe
based videos in the future.

.... and where the *file* on disk is named according to the ID - not
where the ID is just part of the filesystem path leading up to the
video.

HTH,
Jonathan
--
Jonathan Matthews
Oxford, London, UK
http://www.jpluscplusm.com/contact.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rails XSendfile via Nginx

Ari King May 07, 2012 06:54PM

Re: Rails XSendfile via Nginx

Jonathan Matthews May 07, 2012 07:18PM

Re: Rails XSendfile via Nginx

Jonathan Matthews May 07, 2012 07:22PM

Re: Rails XSendfile via Nginx

Ari King May 08, 2012 11:00PM

Re: Rails XSendfile via Nginx

Jonathan Matthews May 09, 2012 06:22AM

Re: Rails XSendfile via Nginx

Francis Daly May 09, 2012 07:26AM

Re: Rails XSendfile via Nginx

Ari King May 09, 2012 05:22PM

Re: Rails XSendfile via Nginx

Ari King May 09, 2012 06:18PM

Re: Rails XSendfile via Nginx

Francis Daly May 09, 2012 06:42PM

Re: Rails XSendfile via Nginx

Francis Daly May 09, 2012 06:40PM

Re: Rails XSendfile via Nginx

Ari King May 10, 2012 04:48PM

Re: Rails XSendfile via Nginx

Francis Daly May 10, 2012 08:38PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 322
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready