2012-08-05 46 views
1

我正在开发一个使用Play Framework的web api。我使用nginx作为反向代理。由于api将被嵌入式系统使用,返回的信息应该尽可能的轻。在生产模式Nginx和原始标头

播放框架excatly此返回:(RAW HTTP从提琴手截取)

HTTP/1.1 200 OK 
Content-Type: text/plain; charset=utf-8 
Cache-Control: no-cache 
Content-Length: 14 

aTqYu1mxQPy|10 

然而,当我置于用户和API之间的nginx,响应变成这样:

HTTP/1.1 200 OK 
Server: nginx/1.2.0 
Date: Sun, 05 Aug 2012 15:08:31 GMT 
Content-Type: text/plain; charset=utf-8 
Content-Length: 14 
Connection: close 
Cache-Control: no-cache 

aTqYu1mxQPy|10 

我不需要服务器,日期,连接标题在所有。它们由nginx自动添加。 (或者是因为我在之前的实验中搞乱了我的nginx配置)

有没有办法告诉ngnix不要告诉任何头文件并且不改变它们?

回答

2

您可以通过使用nginx的第三方模块修改(和删除)的任何标题,https://github.com/agentzh/headers-more-nginx-module
但根据RFC 2616中,HTTP协议,您可以只删除服务器头。
连接:关闭 - 用于关闭持久(HTTP/1.1)连接。
日期头必须在HTTP/1.1呈现,在所有的请求,除了在这些情况下:

1. If the response status code is 100 (Continue) or 101 (Switching 
    Protocols), the response MAY include a Date header field, at 
    the server's option. 

    2. If the response status code conveys a server error, e.g. 500 
    (Internal Server Error) or 503 (Service Unavailable), and it is 
    inconvenient or impossible to generate a valid Date. 

    3. If the server does not have a clock that can provide a 
    reasonable approximation of the current time, its responses 
    MUST NOT include a Date header field 

据我所知,nginx的严格按照RFC来。