2013-04-18 374 views
0

當我們想要通過X重定向鏈傳播Etag作爲範圍請求的Http響應的一部分時,我們遇到了這種奇怪的行爲HTTP 206.似乎nginx通過x-redirect爲非200響應過濾掉了任何額外的costume headers/tmp變量作爲最終響應的一部分。 請提出解決此問題的方法。Nginx:對於Http範圍請求即206,在x重定向鏈的情況下自定義標頭被阻止

下面是調試模式下的正常與範圍請求清除的日誌數據,顯示自定義標頭被過濾掉。

Without Range : 

2013/04/16 04:08:22 [debug] 23457#0: *385 event timer del: 11: 1366110562151 
2013/04/16 04:08:22 [debug] 23457#0: *385 event timer add: 11: 300000:1366110802151 
2013/04/16 04:08:22 [debug] 23457#0: *385 http run request: "get_file?path=/Shared/Documents/loader.html" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http upstream check client, write event:1, "/v2_0/get_file" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http upstream recv(): -1 (11: Resource temporarily unavailable) 
2013/04/16 04:08:22 [debug] 23457#0: *385 http upstream request: "/v2_0/get_file?path=/Shared/Documents/loader.html" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http upstream process header 
2013/04/16 04:08:22 [debug] 23457#0: *385 malloc: 000000000E8621C0:32768 
2013/04/16 04:08:22 [debug] 23457#0: *385 recv: fd:11 1229 of 32646 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy status 200 "200 OK" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy header: "Last-Modified: Tue, 16 Apr 2013 09:47:42 GMT" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy header: "Etag: 0853bce8-bf84-4cc4-9c7e-d4182bafafad" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy header: "Date: Tue, 16 Apr 2013 11:08:22 GMT" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy header: "Server: CherryPy/3.1.2" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy header: "Connection: close" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy header: "Content-Disposition: attachment;filename="loader.html"" 

2013/04/16 04:08:22 [debug] 23457#0: *385 http script complex value 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script set $compressed 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script complex value 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script set $serve_decompressed 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script complex value 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script var: "0853bce8-bf84-4cc4-9c7e-d4182bafafad" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script set $etag 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script complex value 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script var: "Tue, 16 Apr 2013 09:47:42 GMT" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script set $last_modified 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script complex value 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script var: "205" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script set $expected_size 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script complex value 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script var: "205" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script set $actual_size 
-- 
2013/04/16 04:08:22 [debug] 23457#0: *385 malloc: 000000000E906930:32768 
2013/04/16 04:08:22 [debug] 23457#0: *385 posix_memalign: 000000000E90E940:4096 @16 
2013/04/16 04:08:22 [debug] 23457#0: *385 recv: fd:11 350 of 32638 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy status 200 "200 OK" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy header: "Server: Apache-Coyote/1.1" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy header: "Accept-Ranges: bytes" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy header: "Content-Length: 205" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy header: "Date: Tue, 16 Apr 2013 11:08:22 GMT" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy header: "Connection: close" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http proxy header done 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script var: "0853bce8-bf84-4cc4-9c7e-d4182bafafad" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script var: "0853bce8-bf84-4cc4-9c7e-d4182bafafad" 
2013/04/16 04:08:22 [debug] 23457#0: *385 http script var: "Tue, 16 Apr 2013 09:47:42 GMT" 
2013/04/16 04:08:22 [debug] 23457#0: *385 HTTP/1.1 200 OK 
Server: nginx/1.0.4 
Date: Tue, 16 Apr 2013 11:08:22 GMT 
Content-Type: text/html;charset=ISO-8859-1 
Connection: keep-alive 
Content-Disposition: attachment;filename="loader.html" 
Accept-Ranges: none 
Content-Length: 205 
Etag: 0853bce8-bf84-4cc4-9c7e-d4182bafafad 
Last-Modified: Tue, 16 Apr 2013 09:47:42 GMT 
================================================================================= 


With Range : 

2013/04/16 04:07:35 [debug] 23457#0: *373 event timer del: 11: 1366110515893 
2013/04/16 04:07:35 [debug] 23457#0: *373 event timer add: 11: 300000:1366110755894 
2013/04/16 04:07:35 [debug] 23457#0: *373 http run request: "/v2_0/get_file?path=/Shared/Documents/loader.html" 
2013/04/16 04:07:35 [debug] 23457#0: *373 http upstream check client, write event:1, "/v2_0/get_file" 
2013/04/16 04:07:35 [debug] 23457#0: *373 http upstream recv(): -1 (11: Resource temporarily unavailable) 
2013/04/16 04:07:35 [debug] 23457#0: *373 http upstream request: "/v2_0/get_file?path=/Shared/Documents/loader.html" 
2013/04/16 04:07:35 [debug] 23457#0: *373 http upstream process header 
2013/04/16 04:07:35 [debug] 23457#0: *373 malloc: 000000000E8621C0:32768 
2013/04/16 04:07:35 [debug] 23457#0: *373 recv: fd:11 1258 of 32646 
2013/04/16 04:07:35 [debug] 23457#0: *373 http proxy status 200 "200 OK" 
2013/04/16 04:07:35 [debug] 23457#0: *373 http proxy header: "Etag: 0853bce8-bf84-4cc4-9c7e-d4182bafafad" 
2013/04/16 04:07:35 [debug] 23457#0: *373 http proxy header: "Date: Tue, 16 Apr 2013 11:07:35 GMT" 
2013/04/16 04:07:35 [debug] 23457#0: *373 http proxy header: "Server: CherryPy/3.1.2" 
2013/04/16 04:07:35 [debug] 23457#0: *373 http proxy header: "Connection: close" 
2013/04/16 04:07:35 [debug] 23457#0: *373 http proxy header: "Content-Disposition: attachment;filename="loader.html"" 


2013/04/16 04:07:35 [debug] 23457#0: *373 http script complex value 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script set $compressed 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script complex value 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script set $serve_decompressed 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script complex value 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script var: "0853bce8-bf84-4cc4-9c7e-d4182bafafad" 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script set $etag 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script complex value 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script var: "Tue, 16 Apr 2013 09:47:42 GMT" 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script set $last_modified 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script complex value 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script var: "205" 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script set $expected_size 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script complex value 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script var: "205" 
2013/04/16 04:07:35 [debug] 23457#0: *373 http script set $actual_size 

2013/04/16 04:05:18 [debug] 23457#0: *352 http proxy status 206 "206 Partial Content" 
2013/04/16 04:05:18 [debug] 23457#0: *352 http proxy header: "Server: Apache-Coyote/1.1" 
2013/04/16 04:05:18 [debug] 23457#0: *352 http proxy header: "Accept-Ranges: bytes" 
2013/04/16 04:05:18 [debug] 23457#0: *352 http proxy header: "Content-Range: bytes 10-20/205" 
2013/04/16 04:05:18 [debug] 23457#0: *352 http proxy header: "Content-Length: 11" 
2013/04/16 04:05:18 [debug] 23457#0: *352 http proxy header: "Date: Tue, 16 Apr 2013 11:05:18 GMT" 
2013/04/16 04:05:18 [debug] 23457#0: *352 http proxy header: "Connection: close" 
2013/04/16 04:05:18 [debug] 23457#0: *352 http proxy header done 
2013/04/16 04:05:18 [debug] 23457#0: *352 HTTP/1.1 206 Partial Content 
Server: nginx/1.0.4`enter code here` 
Date: Tue, 16 Apr 2013 11:05:18 GMT 
Content-Type: text/html;charset=ISO-8859-1 
Connection: keep-alive 
Content-Disposition: attachment;filename="loader.html" 
Accept-Ranges: none 
Content-Range: bytes 10-20/205 
Content-Length: 11 

回答

1

您迴應雙方都有

Accept-Ranges: none 

表明您的服務器不支持範圍請求。

參考:http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

Servers that do not accept any kind of range request for a 
    resource MAY send 

     Accept-Ranges: none 

    to advise the client not to attempt a range request. 

不知道你的nginx的配置。因爲只有HTTP 1.1支持範圍請求,我的猜測是,你可能會錯過這個指令:

proxy_http_version 1.1; 

Nginx是由默認的代理模塊使用HTTP 1.0。但是,如果您的上游服務器支持http 1.1(它應該),建議使用1.1來獲得更好的性能。 請參閱參考詳細:http://wiki.nginx.org/HttpProxyModule#proxy_http_version

+0

我在aria2c中有無效的範圍標題錯誤,這幫助我謝謝 – cinatic 2017-04-10 14:56:02