On 22/10/10 22:20, Roberto De Ioris wrote:
Il giorno 22/ott/2010, alle ore 13.11, David Taylor ha scritto:

On 21/10/10 22:29, Roberto De Ioris wrote:
Il giorno 21/ott/2010, alle ore 12.55, David Taylor ha scritto:

Hi,

I've worked on a django project, which works fine when running with the debug 
server, but behaves strangely with Cherokee and uWSGI.

With the debug server I can successfully fetch my app's login page using the 
following URLs:

  localhost:8000/app
  localhost:8000/app/
  localhost:8000/app/login

However, when I deploy to Cherokee + uWSGI, the equivalent URLs produce 404s:

  example.com/app
  example.com/app/
  example.com/app/login

After some testing, I found that the following URLs could successfully retrieve 
my app's login page:

  example.com/app/app/
  example.com/app/app/login

Although example.com/app/app still produces a 404.

I have the following in cherokee.conf:

vserver!100!rule!600!encoder!gzip = 1
vserver!100!rule!600!handler = uwsgi
vserver!100!rule!600!handler!balancer = round_robin
vserver!100!rule!600!handler!balancer!source!1 = 31
vserver!100!rule!600!handler!check_file = 0
vserver!100!rule!600!handler!error_handler = 1
vserver!100!rule!600!handler!pass_req_headers = 1
vserver!100!rule!600!match = request
vserver!100!rule!600!match!directory = /app
Here you have mounted the app under /app but as i understand from your mail
you want the application to be under /

If you want the app to live under /app you have to set the mountpoint in the 
xml file
to /app

Your current configuration is inconsistent as you have setup cherokee to mount 
under /app
and uWSGI under /

example.com is WordPress
example.com/app1 is app1 in a Django project
example.com/app2 is app2 in a Django project
etc...

Both app1 and app2 are applications in the same Django project.

I have app1 and app2 handled by the Django project by having rules that match 
directories /app1 and /app2 and use the uwsgi handler.

In that situation what should the single uwsgi.xml file contain?  I have tried 
various mountpoints.  None have worked correctly.

That is a particular situation, not related to uWSGI. When you add a new 
directory/mountpoint in Cherokee the SCRIPT_NAME
WSGI variable will be set. So your app will be /app1/app1 and so on

You have to use a python middleware to solve it, something like this should be 
enough:

def clear_script_name(env, sr):
        env['PATH_INFO'] = env['SCRIPT_NAME'] + env['PATH_INFO']
        env['SCRIPT_NAME'] = ''
         return application(env, sr)



I assume my mountpoint remains "/"?
<uwsgi>
<pythonpath>/var/www/example/</pythonpath>
<pythonpath>/var/www/</pythonpath>
<app mountpoint="/">
<script>django_wsgi</script>
</app>
</uwsgi>

Would I add something like the example code you provided to my django_wsgi.py script?

Inside django_wsgi I currently have:

    import os
    import django.core.handlers.wsgi

    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
    application = django.core.handlers.wsgi.WSGIHandler()

Or are you saying I need to write my own Django middleware? In which case I'm guessing I'd have to write my own process_request?

Thanks Roberto!

Cheers,
David.
_______________________________________________
Cherokee mailing list
[email protected]
http://lists.octality.com/listinfo/cherokee

Reply via email to