Ary*_*rog 22
要在conf.py文件中更改"Server:"http标头,请执行以下操作:
import gunicorn
gunicorn.SERVER_SOFTWARE = 'Microsoft-IIS/6.0'
Run Code Online (Sandbox Code Playgroud)
并使用沿线的调用 gunicorn -c conf.py wsgi:app
要完全删除标题,你可以通过用过滤掉标题的子类替换它的http响应类来修补gunicorn.这可能是无害的,但可能不推荐.将以下内容放在conf.py中:
from gunicorn.http import wsgi
class Response(wsgi.Response):
def default_headers(self, *args, **kwargs):
headers = super(Response, self).default_headers(*args, **kwargs)
return [h for h in headers if not h.startswith('Server:')]
wsgi.Response = Response
Run Code Online (Sandbox Code Playgroud)
用gunicorn测试18
这里还没有明确写出来,所以我要确认最新版本的 Gunicorn (20.1.x) 的最简单方法是将以下行添加到配置文件中:
import gunicorn
gunicorn.SERVER = 'undisclosed'
Run Code Online (Sandbox Code Playgroud)
gunicorn.conf.py
对于较新版本 (20.0.4):在运行命令的目录中创建一个包含以下内容的文件gunicorn
:
import gunicorn
gunicorn.SERVER_SOFTWARE = 'My WebServer'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3819 次 |
最近记录: |