Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache2 mod_wsgi 403 forbidden error

I had it configured right, but then I decided to reinstall my Debian (switching from wheezy to jessie version by the way). Here's the problem:

I have a python mod_wsgi application at: /mnt/doc/Python/www/index.py.

$ ls -l / | grep mnt
drwxr-xr-x   3 root root  4096 sty 12 09:36 mnt

$ ls -l /mnt
drwxrwxrwx 1 sven sven 20480 sty  7 19:34 doc

$ ls -l /mnt/doc/Python/www/
total 12
drwxrwxrwx 1 sven sven 4096 Jan  3 19:52 core
-rwxrwxrwx 1 sven sven    0 Dec 22 13:25 __init__.py
drwxrwxrwx 1 sven sven    0 Dec 24 00:11 silva
-rwxrwxrwx 1 sven sven  984 Dec 22 13:47 silva.py
-rwxrwxrwx 1 sven sven  697 Dec 25 13:32 txt

All subdirectories have the same permissions as /mnt/doc, but still I get 403 Forbidden error, when trying to open the site. It's configuration below:

WSGIScriptAlias /huh /mnt/doc/Python/www/index.py                 
<Directory /mnt/doc/Python/www>                                   
    Order allow,deny                                                            
    Allow from all                                                              
</Directory>

When trying to open the page, the following message appears in Apache2 log:

[authz_core:error] [pid 15269:tid 140518201730816] [client ::1:44130] AH01630: client denied by server configuration: /mnt/doc/Python/www/index.py

I'm pretty sure that I copied previous configuration quite exactly. Did anything change recently?

EDIT: I neglected to add that I use Python 3.3 and libapache2-mod-wsgi-py3 Debian package.

like image 385
Sventimir Avatar asked Jan 14 '14 19:01

Sventimir


3 Answers

I solved it finally. pxl was half-right, because not only Allow from all should be replaced by Require all granted, but also Order allow,deny is no longer necessary. It turns out to be the reason for my error. Complete script alias config should be like this:

WSGIScriptAlias /huh /mnt/doc/Python/www/index.py                 
<Directory /mnt/doc/Python/www>                                   
    Require all granted
</Directory>

And it works.

like image 193
Sventimir Avatar answered Nov 18 '22 13:11

Sventimir


Replace Allow from all with Require all granted.

Reference for Apache module mod_authz_core

like image 27
P̲̳x͓L̳ Avatar answered Nov 18 '22 13:11

P̲̳x͓L̳


I wrote like below,

    WSGIScriptAlias /hello /home/myself/projects/hello/hello.wsgi
    <Directory /home/myself/projects/hello>
    Order allow,deny
    Allow from all
    Require all granted
    </Directory>

and it works

like image 3
user1960422 Avatar answered Nov 18 '22 14:11

user1960422