How to remove the “Server” HTTP response header from my Rack app

只愿长相守 提交于 2020-01-04 07:09:07

问题


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. Inspecting the response headers gives me:

Server:thin 1.5.0 codename Knife

Can anyone point me in the right direction?


回答1:


This Server header is set by the Thin server when assembling the response. A recent commit adds the ability to set the Server to something else, but it doesn’t look like you can totally remove it.

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.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.



来源:https://stackoverflow.com/questions/13692701/how-to-remove-the-server-http-response-header-from-my-rack-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!