简体   繁体   English

如何防止读取原始WSGI python文件?

[英]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.

相关问题 如何使用Python防止文件被复制? - How do I use Python to prevent a file from being copied? 我来自 csv 文件的文本被读取为原始字符串。 它包含“it\'s”而不是 it's。 我该如何清洁这个? - My text from csv file is being read as raw string. It contains “it\'s” instead of it's. How do I clean this? 如何防止在 Python 中引发自定义异常? - How do I prevent a custom exception from being raised in Python? 如何覆盖Python当前正在读取的文件 - How do I overwrite a file currently being read by Python 如何保护Python代码不被用户读取? - How do I protect Python code from being read by users? Python rawkit 如何从 RAW 文件中读取元数据值? - Python rawkit how read metadata values from RAW file? Python如何从文件中读取原始二进制文件? (音频/视频/文本) - Python how to read raw binary from a file? (audio/video/text) 如何防止在Python中从两个不同的变量生成两个相同的随机数? - How do I prevent two of the same random numbers being generated from two different variables in Python? 从python中的txt读取原始音频文件 - Read raw audio file from txt in python python-从原始图像文件读取标头 - python - read header from raw image file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM