Forum: NGINX Help- can't see subdirectories for static content location

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
equalium (Guest)
on 2009-03-27 11:13
(Received via mailing list)
Hello, I'm setting up nginx to serve a django site. The django part goes
OK but
I have a problem with my media directory. I'm using this:

location /media/ {
   root   /home/django/domains/myapp/static/;
}

...

The problem is that I can access that directory and any html file
directly
inside but not other directories or images.

For example, my directories are like this:

./domains
...myapp
......static
.........CSS
.........images
.........js
.........hello.html
.........image.png

I have the option "autoindex on;", so when I access:
http://mydomain/media/ I see:

Index of /media/
../
hello.html

Does anybody know what can be wrong?

Thanks for any suggestion.
Igor S. (Guest)
on 2009-03-27 11:22
(Received via mailing list)
On Fri, Mar 27, 2009 at 09:01:57AM +0000, equalium wrote:

> inside but not other directories or images.
Probably, you have also something like this:

    location ~ \.(gif|png|jpg|css|js)$ {

You may delete it if it is not needed, or may disable regex tests for
/media/:

    location ^~ /media/ {

>
> I have the option "autoindex on;", so when I access: http://mydomain/media/ I see:
>
> Index of /media/
> ../
> hello.html
>
> Does anybody know what can be wrong?

Do you see in the listing just index.html without image.png, etc. ?
Carlos (Guest)
on 2009-03-27 12:06
(Received via mailing list)
Hi,

I have nothing for (gif|png...)
I have just tried your suggestion: "location ^~ /media/ " but isn't
still
working.

Thank for your quick reply. From your last question (yes, I only see one
.html file) I have discovered something weird. I have added more files
to
the directory, even more .html files and I can't see none of them so I
guess
it must a problem about user:group permissions or cache (I have no
"expires"
option at the config file) or whatever else.

I have created most of the files not directly on the server but in a nfs
mount on an ubuntu client (it's a intranet), although now I have created
some directly on the host but don't work either.
I have restarted both nginx and apache to be sure.
Well I'll keep investigating as I'm relatively new to linux and will
post
the solution once I find it.

I'm excited for having discovered nginx and for your helpful assistance.
I welcome any other suggestion to try although it seems not to be an
nginx
issue.

Thank you and greetings from Barcelona.

Carlos.


2009/3/27 Igor S. <removed_email_address@domain.invalid>
Carlos (Guest)
on 2009-03-27 13:17
(Received via mailing list)
I got it!!!

I had misunderstood the location /media/ function.

I thought that /media/ was a virtual name for the root string.
I see that in fact /media/ is a directory that must exist in the root.

What confused me was that in fact, trying and trying, I had created a
media
folder and copied one html file into it but I forgot about that. So, I
thougth that I was seeing only that html from the /static/ dir while I
was
seeing the copy at /static/media/.

Anyway this silly thing has helped me to understand nginx and its
configuration a little better.

Thank you and best wishes.



2009/3/27 Igor S. <removed_email_address@domain.invalid>
Jean-Philippe M. (Guest)
on 2009-03-27 14:46
(Received via mailing list)
Carlos a écrit :
> I got it!!!
>
> I had misunderstood the location /media/ function.
>
> I thought that /media/ was a virtual name for the root string.
> I see that in fact /media/ is a directory that must exist in the root.
>

You can use alias if you don't want to create a media folder in your
static
directory.
Carlos (Guest)
on 2009-03-27 18:08
(Received via mailing list)
2009/3/27 Jean-Philippe M. <removed_email_address@domain.invalid>

> directory.
>
>
Merci, Jean-Philippe. "alias", that's what I wanted at first. Merci
beaucoup.
This topic is locked and can not be replied to.