[英]How do I prevent the raw WSGI python file from being read?
I am using mod_wsgi with apache to serve the python application. 我正在将mod_wsgi与apache一起使用以服务python应用程序。 I have a directive in the VirtualHost entry as follows WSGIScriptAlias /app /home/ubuntu/www/app.wsgi
. 我在VirtualHost条目中有一条指令,如下所示: WSGIScriptAlias /app /home/ubuntu/www/app.wsgi
。 I also have DocumentRoot /home/ubuntu/www/
. 我也有DocumentRoot /home/ubuntu/www/
。 Therefore, if the user attempts to read /app.wsgi it gets the raw file. 因此,如果用户尝试读取/app.wsgi,它将获取原始文件。 If I try to block access to it via .htaccess, the application becomes unusable. 如果我尝试通过.htaccess阻止对其进行访问,则该应用程序将变得无法使用。 How do I fix this? 我该如何解决? Is there a way to do so without moving the file out of the DocumentRoot? 有没有一种方法可以将文件移出DocumentRoot?
这远非最佳选择,但它似乎确实有效:我WSGIScriptAlias /app.wsgi /home/ubuntu/www/app.wsgi
添加到VirtualHost中,以便它将在该uri上运行该应用程序而不返回原始文件。
You should not stick the WSGI file in the DocumentRoot directory in the first place. 您不应首先将WSGI文件粘贴在DocumentRoot目录中。 You have created the situation yourself. 您已经创建了这种情况。 It doesn't need to be in that directory for WSGIScriptAlias to work. WSGIScriptAlias不必在该目录中即可工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.