This question arises from the answer to: How to set up multiple accounts with separate databases for Django on the same server?
I haven’t seen anything like it on Google or elsewhere (maybe I have the wrong dictionary), so I believe that input can be a valuable addition to online discussions.
How to configure the server configuration:
- One Lighttpd installation
- Several Django projects running FastCGI
- Django projects can be added / removed as desired and do not require a web server restart
- Transparently redirecting all requests / responses to a specific Django installation depending on the current user
those. Given the Django projects (with the corresponding FastCGI socket):
- Bob (/tmp/bob.fcgi)
- Sue (/tmp/sue.fcgi)
- Joe (/tmp/joe.fcgi)
Django projects start with a (simplified) script likeso:
#!/bin/sh
NAME=bob
SOCKET=/tmp/$NAME.fcgi
PROTO=fcgi
DAEMON=true
/django_projects/$NAME/manage.py runfcgi protocol=$PROTO socket=$SOCKET
daemonize=$DAEMON
I want traffic to http://www.example.com/ to redirect the request to the correct Django application depending on the user who is logged in.
In other words, http://www.example.com should show "be" /tmp/bob.fcgi if bob is logged in, /tmp/joe.fcgi if joe is logged in, /tmp/sue.fcgi, if sue is logged in. If no one is logged in, he should redirect to the login page.
I reviewed the demultiplexing "plexer" FastCGI script with the following algorithm:
If the cookie is set to $ PLEX, the channel request in / tmp / $ PLEX.fcgi
( cookie PLEX Username = > PLEX)
, $PLEX , $PLEX .
Lighttpd ( Apache, Nginx .. ):
fastcgi.server = ( "plexer.fcgi" =>
( "localhost" =>
(
"socket" => "/tmp/plexer.fcgi",
"check-local" => "disable"
)
)
)
, , plexer FastCGI, .
.