Mobile app version of vmapp.org
Login or Join
Phylliss660

: A WSGI-configured Apache does not serve images from /static or /media (Django), returns 403 I have set up an Apache server with WSGI/Django on it, and everything works fine -- html, css --

@Phylliss660

Posted in: #Apache #Django #StaticContent

I have set up an Apache server with WSGI/Django on it, and everything works fine -- html, css -- but when I try to request an image file, like png, it returns 403 Forbidden. The configuration is as follows:

sites-available/default

WSGIScriptAlias / /var/djangoblog/myDjangoBlog/wsgi.py

<Directory /var/djangoblog/myDjangoBlog>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>

Alias /robots.txt /var/www/robots.txt
Alias /favicon.ico /var/www/favicon.ico

Alias /static/ /var/djangoblog/static/
Alias /media/ /var/djangoblog/media/

<Directory /var/djangoblog/static>
Order allow,deny
Allow from all
</Directory>

<Directory /var/djangoblog/media>
Order allow,deny
Allow from all
</Directory>


I also tried to allow from all in httpd.conf, but no luck.

Could you please help me?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Phylliss660

1 Comments

Sorted by latest first Latest Oldest Best

 

@Debbie626

Most likely, this is a posix-permissions-issue or an selinux-context-issue. I would check to see that the png files in question are readable to your web-server user/group and are permissions 755. To check selinux contexts, try an "ls -RZl /var/djangoblog" and see that the contexts listed are the same for files that are served and files that are not.

After that, this is far less likely. Apache might be filtering the files, doubtful by default but in the huge open source wilderness where we don't know what distro you are on, it is a possibility. (debian, CentOS?)

Check httpd.conf and any conf.d/ like files/directories (anything that contains apache directives) especially for a line such as <FilesMatch ".(gif|jpg|jpeg|png)$"> which could be matching and rejecting the requests for those png files. These apache global files might be overaliasing the sites-enabled/default instance also, if they incidentally contain any /media/ // aliases.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme