2012-08-05 48 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來。