Re: apache2+mod_wsgi: 403 Forbidden

452 views
Skip to first unread message
Message has been deleted

Matias

unread,
Sep 7, 2009, 4:11:15 PM9/7/09
to django...@googlegroups.com
I think you missed the allow directive in your apache conf.

Example from [1]
Alias /media/ /usr/local/django/mysite/media/

<Directory /usr/local/django/mysite/media>
Order deny,allow
Allow from all
</Directory>

WSGIScriptAlias /
/usr/local/django/mysite/apache/django.wsgi

<Directory /usr/local/django/mysite/apache>
Order deny,allow
Allow from all
</Directory>
[1] http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango


HTH,
Matias.

On Mon, Sep 7, 2009 at 2:55 PM, Léon Dignòn <leon....@gmail.com> wrote:

I get a 403 forbidden.

I serve Django with apache2+mod_wsgi. I disabled some plugins I think
I don't need. Set the listen port to 8000 on localhost only. Later I
will serve django through reverse proxy on cherokee webserver. But for
now, localhost:8000 is returning a 403 forbidden error.

Any ideas?




# error.log
   [Mon Sep 07 17:14:59 2009] [error] [client 127.0.0.1] client
denied by server configuration: /htdocs


lwp-request -m GET -Sed http://127.0.0.1:8000/
lwp-request
-m GET -Sed http://beispiel.de:8000/
   GET http://127.0.0.1:8000/ --> 403 Forbidden
   Connection: close
   Date: Mon, 07 Sep 2009 14:56:32 GMT
   Server: Apache
   Content-Length: 202
   Content-Type: text/html; charset=iso-8859-1
   Client-Date: Mon, 07 Sep 2009 14:56:32 GMT
   Client-Peer: 127.0.0.1:8000
   Client-Response-Num: 1
   Title: 403 Forbidden


# /etc/apache2/ports.conf
   NameVirtualHost 127.0.0.1:8000
   Listen 127.0.0.1:8000


# /etc/apache2/sites-enabled/000-default
   <VirtualHost 127.0.0.1:8000>
           ServerName localhost
           ServerAdmin webmaster@localhost
   </VirtualHost>



# /etc/apache2/sites-enabled/beispiel.de
   <VirtualHost 127.0.0.1:8000>
           ServerName www.beispiel.de
           ServerAlias beispiel.de
           ServerAdmin daniel....@gmail.com

           DocumentRoot /var/www/django/beispiel

           Alias /robots.txt  /var/www/django/beispiel/media/
robots.txt
           Alias /favicon.ico /var/www/django/beispiel/media/
favicon.ico
           Alias /media/      /var/www/django/beispiel/media/

           ErrorLog  "|/usr/sbin/rotatelogs /var/log/apache2/
beispiel.de/error_log.%Y-%m-%d 86400"
           CustomLog "|/usr/sbin/rotatelogs /var/log/apache2/
beispiel.de/access_log.%Y-%m-%d 86400" common

           WSGIScriptAlias / /var/www/django/wsgi-scripts/
beispiel.wsgi
   </VirtualHost>


# mods-enabled
   alias.conf
   alias.load
   auth_digest.load
   authn_file.load
   authz_default.load
   authz_groupfile.load
   authz_host.load
   authz_user.load
   status.conf
   status.load
   wsgi.conf
   wsgi.load




--
:wq

Léon Dignòn

unread,
Sep 7, 2009, 4:56:54 PM9/7/09
to Django users
No, I have it here, but forgot to post it:

<Directory />
Order Allow,Deny
Deny from all
</Directory>
<Directory /var/www/>
Order Allow,Deny
Allow from all
</Directory>
> > lwp-request <http://127.0.0.1:8000/%0Alwp-request> -m GET -Sed
> >http://beispiel.de:8000/
> >    GEThttp://127.0.0.1:8000/--> 403 Forbidden
> >    Connection: close
> >    Date: Mon, 07 Sep 2009 14:56:32 GMT
> >    Server: Apache
> >    Content-Length: 202
> >    Content-Type: text/html; charset=iso-8859-1
> >    Client-Date: Mon, 07 Sep 2009 14:56:32 GMT
> >    Client-Peer: 127.0.0.1:8000
> >    Client-Response-Num: 1
> >    Title: 403 Forbidden
>
> > # /etc/apache2/ports.conf
> >    NameVirtualHost 127.0.0.1:8000
> >    Listen 127.0.0.1:8000
>
> > # /etc/apache2/sites-enabled/000-default
> >    <VirtualHost 127.0.0.1:8000>
> >            ServerName localhost
> >            ServerAdmin webmaster@localhost
> >    </VirtualHost>
>
> > # /etc/apache2/sites-enabled/beispiel.de
> >    <VirtualHost 127.0.0.1:8000>
> >            ServerNamewww.beispiel.de
> >            ServerAlias beispiel.de
> >            ServerAdmin daniel.nicc...@gmail.com
> :wq- Hide quoted text -
>
> - Show quoted text -

Matias

unread,
Sep 8, 2009, 10:04:34 AM9/8/09
to django...@googlegroups.com
You should use Directory with the real path, not the alias

<Directory /var/www/django/wsgi-scripts>

       Order Allow,Deny
       Deny from all
</Directory>
<Directory /var/www/>
       Order Allow,Deny
       Allow from all
</Directory>

like in the example :)

Regards,
Matias.
--
:wq

Matias

unread,
Sep 8, 2009, 10:28:19 AM9/8/09
to django...@googlegroups.com
sorry, I messed up!

I'm not sure now, i couldn't test it, but maybe you should set the Directory directive in the specific path where wsgi files are


<Directory />
       Order Allow,Deny
       Deny from all
</Directory>
<Directory /var/www/django/wsgi-scripts>

       Order Allow,Deny
       Allow from all
</Directory>

Regards,
Matias.
--
:wq

Graham Dumpleton

unread,
Sep 8, 2009, 7:21:24 PM9/8/09
to Django users


On Sep 9, 12:28 am, Matias <gonzalezmat...@gmail.com> wrote:
> sorry, I messed up!
>
> I'm not sure now, i couldn't test it, but maybe you should set the Directory
> directive in the specific path where wsgi files are
>
> <Directory />
>        Order Allow,Deny
>        Deny from all
> </Directory>
> <Directory */var/www/django/wsgi-scripts*>

Don't use wildcards, ie., '*', like that, it is unnecessary in this
sort of situation and technically will match other directories you may
not have intended to expose, if they so happened to exist.

Graham

>        Order Allow,Deny
>        Allow from all
> </Directory>
>
> Regards,
> Matias.
>
>
>
>
>
> On Tue, Sep 8, 2009 at 11:04 AM, Matias <gonzalezmat...@gmail.com> wrote:
> > You should use Directory with the real path, not the alias
>
> > <Directory */var/www/django/wsgi-scripts*>
> >        Order Allow,Deny
> >        Deny from all
> > </Directory>
> > <Directory /var/www/>
> >        Order Allow,Deny
> >        Allow from all
> > </Directory>
>
> > like in the example :)
>
> > Regards,
> > Matias.
>

Léon Dignòn

unread,
Sep 9, 2009, 5:41:25 AM9/9/09
to Django users
I solved the Problem. It was my fault and because of that the default
virtual host served the request. :(

Thank you for your help!
> > :wq- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
Reply all
Reply to author
Forward
0 new messages