开发者

Apache basic authentication on Django site

开发者 https://www.devze.com 2022-12-19 15:17 出处:网络
I\'m trying to add basic Apache name/password authentication to a running Django site. I\'ve following the example here. I\'ve created an .htpasswd file and have the following in httpd.conf:

I'm trying to add basic Apache name/password authentication to a running Django site.

I've following the example here. I've created an .htpasswd file and have the following in httpd.conf:

WSGIScriptAlias / /home/ann/webapps/django/domesday.wsgi
<Directory /home/ann/webapps/apache2>
AuthType Basic
AuthName "Authentication Required"
AuthUserFile "/home/ann/webapps/django/domesday/.htpasswd"
Require valid-user
</Directory>

However, when I try to start Apache, I get the error message:

[annaps@web121 apache2]$ bin/restart 
Apache isn't running.
Syntax error on line 25 of /home/annaps/webapps/django/apache2/conf/httpd.conf:
Invalid command 'AuthUserFile', perhaps misspelled or defined by a module not included in the server configuration

What am I doing wrong? As far as I can tell, this is an exact copy of all the examples.

I don't need to specify paths to protect - just the whole site is fine. I'm not totally sure what to put in the <Directory> tag though - the root of my Django project, the root 开发者_如何学Pythonof Apache (as here), or something else?


From http://readthefuckingmanual.net/error/1385/ (I didn't pick that URL intentionally I swear!):

Make sure you have this in your httpd.conf:

LoadModule authn_file_module modules/mod_authn_file.so


AuthUserFile is part of mod_authn_file, which is only available in 2.1. Make sure that the module is loaded if it exists. And if it doesn't... you won't be able to use that directive.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号