当通过mod_wsgi提供Django应用程序时,我注意到了一个奇怪的错误。
在我的文档根目录中,我使用LocationMatch指令将/admin目录限制为127.0.0.1。 我也有/admin URLConf挂载/在Django应用程序,这是Django的自动生成的pipe理界面的标准path。 该应用程序本身位于/apppath下,使用WSGIScriptAlias指令进行configuration。
现在,Apache以某种方式将每个请求处理为/app/admin并将其子path定向为应用程序和文档根目录。 我得到Django的pipe理显示,但是error.log包含这样一行: [Tue Feb 14 01:25:35.538501 2017] [authz_core:error] [pid 29235] [client 32.135.203.150:36412] AH01630: client denied by server configuration: /var/www/html/admin/
除了两件事之外,这几乎不是问题:
这是通过重命名我的html目录或Django的pipe理应用程序来解决的,但我真的很想find正确的解决scheme,让我有两个。
Debian中的Apacheconfiguration被分割成多个文件,但我相信相关的部分如下:
<VirtualHost *:80> ServerAdmin webmaster@localhost SetOutputFilter DEFLATE BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html Include conf-available/default.conf DocumentRoot /var/www/html <LocationMatch ^/admin> Require ip 127.0.0.1 ::1 </LocationMatch> <LocationMatch ^/admin/status> SetHandler server-status </LocationMatch> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn SetEnvIf Request_URI "/admin/status" nolog CustomLog ${APACHE_LOG_DIR}/access.log combined env=!nolog </VirtualHost>
default.conf:
<Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/html> Options Indexes FollowSymLinks MultiViews DirectoryIndex disabled AllowOverride Indexes Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> Alias /app/static/ /var/www/app/static/ Alias /app/media/ /var/www/app/media/ <Directory /var/www/app/static> Require all granted </Directory> <Directory /var/www/app/media> Require all granted </Directory> WSGIDaemonProcess pbf.net.pl python-path=/var/www/app:/usr/local/virtualenvs/app/lib/python3.4/site-packages/ WSGIProcessGroup app WSGIScriptAlias /app /var/www/app/wsgi.py process-group=app # WSGIPythonPath /var/www/app/ <Directory /var/www/app> <Files wsgi.py> Require all granted </Files> </Directory>