Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am attempting to configure Apache to host multiple django sites via mod_wsgi. The mod_wsgi setup tutorial gives an example configuration for this scenario where each app is in the same directory:

WSGIScriptAliasMatch ^/([^/]+) /usr/local/django/$1/apache/django.wsgi

<DirectoryMatch ^/usr/local/django/([^/]+)/apache>
    Order deny,allow
    Allow from all
</DirectoryMatch>

I'm trying to extend this example to add a password file created for each application to use http authentication. I figured I could do this by setting up a seperate parallel directory for each app and reference the matched directory name in the way that is done in WSGIScriptAliasMatch, like such:

WSGIScriptAliasMatch ^/([^/]+) /usr/local/django/$1/apache/django.wsgi

<DirectoryMatch ^/usr/local/django/([^/]+)/apache>
    AuthType Basic
    AuthUserFile /usr/local/django-auth/$1/users.passwd
    AuthGroupFile /dev/null
    Require valid-user
</DirectoryMatch>

I had assume that '$1' would expand to the parans matched by the regex for the DirectoryMatch, however I can't authenticate and my error log states:

No such file or directory: Could not open password file: /usr/local/django-auth/$1/users.passwd

So it seems like the '$1' isn't being expended to the matched app like I assumed it would. Is there any way to accomplish this? I don't want to have to add a new directive for each site as it pops up.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

AuthUserFile path is static and there is no way it can be expanded based on the URL.

You should perhaps instead look at:

http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms

This would allow you to provide your own authentication provider. This could look at request information in the 'environ' dictionary passed to your check_password() function and based on that validate a user against a specific user database.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.