12

構成:

  • リバース プロキシとしての Nginx + SSL ネゴシエーション
  • アパッチ トムキャット。

ファイルのアップロードを除いて、すべて正常に動作しているようです。何らかの理由でファイルのアップロードが完了しません。以下の構成で、小さなファイル (4K) をアップロードできます。194K ファイルでアップロードが失敗します。「client_body_buffer_size」を 256K に増やすと、194K のファイルはアップロードできますが、500K のファイルのアップロードは失敗します。「client_body_buffer_size」を 256K を超えて増やしても影響はありません。

注: Tomcat に直接アクセスして 500K ファイルをアップロードすると、数ミリ秒で完了します。

そのため、Nginx の設定に問題があるようです。どんな提案でも大歓迎です。

    upstream tomcat_server {
        server 127.0.0.1:9090 fail_timeout=0;
        keepalive 16;
    }

location / {
                root   /xyz;
                proxy_http_version 1.1;
           proxy_pass http://tomcat_server;
            proxy_set_header Connection "";
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_buffering         on;
            proxy_connect_timeout 75;
            proxy_send_timeout 180;
            proxy_read_timeout 1200;

        keepalive_timeout  120;
        proxy_buffer_size   128k;
        proxy_buffers   4 256k;
        proxy_busy_buffers_size   256k;
       proxy_temp_path /tmp/nginx/proxy;
       proxy_temp_file_write_size 1000m;

            }

nginx config (client_body_temp_path、proxy_temp_path、proxy_temp_file_write_size) に他のいくつかのパラメーターを追加しようとしました。彼らは役に立たないようでした。

====

更新 - 2013/07/30:

さらに調査した結果、196K 以上のファイルのアップロードに問題があることが判明しました。194K ファイルが動作します。「client_body_buffer_size」の値は 256K に設定されています。

失敗した場合、Nginx デバッグ ログには次のように表示されます。

2013/07/30 16:29:57 [debug] 14208#0: *1 recv: fd:11 2606 of 16384
2013/07/30 16:29:57 [debug] 14208#0: *1 http proxy status 200 "200 OK"
2013/07/30 16:29:57 [debug] 14208#0: *1 http proxy header: "Server: Apache-Coyote/1.1"
2013/07/30 16:29:57 [debug] 14208#0: *1 http proxy header: "Content-Type: text/html;charset=utf-8"
2013/07/30 16:29:57 [debug] 14208#0: *1 http proxy header: "Date: Tue, 30 Jul 2013 22:29:57 GMT"
2013/07/30 16:29:57 [debug] 14208#0: *1 http proxy header: "Connection: close"
2013/07/30 16:29:57 [debug] 14208#0: *1 http proxy header done
2013/07/30 16:29:57 [debug] 14208#0: *1 xslt filter header
2013/07/30 16:29:57 [debug] 14208#0: *1 HTTP/1.1 200 OK^M
Server: nginx/1.5.2^M
Date: Tue, 30 Jul 2013 22:29:57 GMT^M
Content-Type: text/html;charset=utf-8^M
Transfer-Encoding: chunked^M
Connection: keep-alive^M

2013/07/30 16:29:57 [debug] 14208#0: *1 write new buf t:1 f:0 000000001E61DAD8, pos 000000001E61DAD8, size: 168 file: 0, size: 0
2013/07/30 16:29:57 [debug] 14208#0: *1 http write filter: l:0 f:0 s:168
2013/07/30 16:29:57 [debug] 14208#0: *1 http cacheable: 0
2013/07/30 16:29:57 [debug] 14208#0: *1 posix_memalign: 000000001E62D450:4096 @16
2013/07/30 16:29:57 [debug] 14208#0: *1 http proxy filter init s:200 h:0 c:0 l:-1
2013/07/30 16:29:57 [debug] 14208#0: *1 http upstream process upstream
2013/07/30 16:29:57 [debug] 14208#0: *1 pipe read upstream: 1
2013/07/30 16:29:57 [debug] 14208#0: *1 pipe preread: 2465
2013/07/30 16:29:57 [debug] 14208#0: *1 readv: 1:13778
2013/07/30 16:29:57 [debug] 14208#0: *1 readv() not ready (11: Resource temporarily unavailable)
2013/07/30 16:29:57 [debug] 14208#0: *1 pipe recv chain: -2
2013/07/30 16:29:57 [debug] 14208#0: *1 pipe buf free s:0 t:1 f:0 000000001E61DBD0, pos 000000001E61DC5D, size: 2465 file: 0, size: 0
2013/07/30 16:29:57 [debug] 14208#0: *1 pipe length: -1
2013/07/30 16:29:57 [debug] 14208#0: *1 pipe write downstream: 1
2013/07/30 16:29:57 [debug] 14208#0: *1 pipe write busy: 0
2013/07/30 16:29:57 [debug] 14208#0: *1 pipe write: out:0000000000000000, f:0
2013/07/30 16:29:57 [debug] 14208#0: *1 pipe read upstream: 0
2013/07/30 16:29:57 [debug] 14208#0: *1 pipe buf free s:0 t:1 f:0 000000001E61DBD0, pos 000000001E61DC5D, size: 2465 file: 0, size: 0
2013/07/30 16:29:57 [debug] 14208#0: *1 pipe length: -1
2013/07/30 16:29:57 [debug] 14208#0: *1 event timer add: 11: 180000:1375223577332
2013/07/30 16:29:57 [debug] 14208#0: *1 http upstream request: "/upload/html?"
2013/07/30 16:29:57 [debug] 14208#0: *1 http upstream send request handler
2013/07/30 16:29:57 [debug] 14208#0: timer delta: 6
2013/07/30 16:29:57 [debug] 14208#0: posted events 0000000000000000
2013/07/30 16:29:57 [debug] 14208#0: worker cycle
2013/07/30 16:29:57 [debug] 14208#0: epoll timer: 179994

上記のログ スニペットに「http アップストリーム送信要求ハンドラー」があることに気付きました。成功した場合と同様に、次のように表示されます。

2013/07/30 16:29:44 [debug] 14208#0: *1 http upstream dummy handler

「http アップストリーム送信リクエスト ハンドラー」と「http アップストリーム ダミー ハンドラー」が何を意味し、何を意味するのか考えていますか?

4

2 に答える 2

18

私も同じ問題を抱えていました。Michael Härtl の答えは正しいです。私の場合、これはトリックを行ったセットアップでした:

nginx.conf に以下を追加します。

http {
     # at the END of this segment!
     client_max_body_size 1000m;
}
于 2014-05-19T11:51:50.560 に答える