[英]How to remove the “Server” HTTP response header from my Rack app
I am trying to remove the server information from the http response header in my ruby on rails application running on Heroku but I am stuck. 我正在尝试从运行在Heroku上的ruby on rails应用程序中的http响应标头中删除服务器信息,但是我被卡住了。 Inspecting the response headers gives me:
检查响应头给我:
Server:thin 1.5.0 codename Knife
Can anyone point me in the right direction? 谁能指出我正确的方向?
This Server
header is set by the Thin server when assembling the response. 组装响应时,此
Server
标头由Thin服务器设置 。 A recent commit adds the ability to set the Server
to something else , but it doesn't look like you can totally remove it. 最近的提交增加了将
Server
设置为其他功能的能力 ,但是看起来您无法完全删除它。
One thing you can do is to set the value of the Thin::VERSION
contsant to nil
, which results in no Server
header being sent: 您可以做的一件事是将
Thin::VERSION
常量的值设置为nil
,这将导致不发送任何Server
标头:
Thin.send :remove_const, :SERVER
Thin::SERVER = nil
The first line is to avoid the warning that would be generated when altering a constant. 第一行是避免在更改常数时生成警告。 Now when Thin tries to set the
Server
header it sees it is nil
and skips it , so no header is set at all. 现在,当Thin尝试设置
Server
标头时,它会看到它为nil
并跳过它 ,因此根本没有设置标头。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.