developer tip

업스트림이 너무 큼-nginx + codeigniter

optionbox 2020. 12. 27. 10:39
반응형

업스트림이 너무 큼-nginx + codeigniter


Nginx에서이 오류가 발생하지만 알아낼 수없는 것 같습니다! 저는 codeigniter를 사용하고 있으며 세션에 데이터베이스를 사용하고 있습니다. 그래서 헤더가 어떻게 너무 커질 수 있는지 궁금합니다. 어쨌든 헤더가 무엇인지 확인할 수 있습니까? 또는 잠재적으로이 오류를 수정하기 위해 무엇을 할 수 있는지 볼 수 있습니까?

conf 파일이나 기타 파일을 올려야하는지 알려 주시면 요청하시면 업데이트하겠습니다.

2012/12/15 11:51:39 [error] 2007#0: *5778 upstream sent too big header while reading response header from upstream, client: 24.63.77.149, server: jdobres.xxxx.com, request: "POST /main/login HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "jdobres.xxxxx.com", referrer: "http://jdobres.xxxx.com/"

최신 정보

conf에 다음을 추가했습니다.

proxy_buffer_size   512k;
proxy_buffers   4 512k;
proxy_busy_buffers_size   512k;

그리고 이제 나는 여전히 다음을 얻습니다.

2012/12/16 12:40:27 [error] 31235#0: *929 upstream sent too big header while reading response header from upstream, client: 24.63.77.149, server: jdobres.xxxx.com, request: "POST /main/login HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "jdobres.xxxx.com", referrer: "http://jdobres.xxxx.com/"

당신이 추가 http {}nginx.conf의 정상에있는 파일 /etc/nginx/nginx.conf :

proxy_buffer_size   128k;
proxy_buffers   4 256k;
proxy_busy_buffers_size   256k;

그런 다음 이것을 PHP 위치 블록에 추가하면 가상 호스트 파일에 위치 하여 위치 ~ .php $ {로 시작하는 블록을 찾습니다.

fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;

nginx 구성을 수정하고 다음 지시문을 변경 / 설정합니다.

    proxy_buffer_size   128k;
    proxy_buffers   4 256k;
    proxy_busy_buffers_size   256k;

유효하지 않은 헤더가 전송 될 때도 전송된다는 것을 증명했습니다. HTTP 헤더의 잘못된 문자 또는 형식 지정, 한 달 이상 쿠키 만료 설정 등은 모두 업스트림에서 응답 헤더를 읽는 동안 너무 큰 헤더를 보냈습니다.


nginx + fcgiwrap + 너무 긴 요청 사용

nginx + fcgiwrap 구성을 사용하기 때문에 동일한 문제가 발생했습니다.

location ~ ^.*\.cgi$ {
    fastcgi_pass  unix:/var/run/fcgiwrap.sock;
    fastcgi_index index.cgi;
    fastcgi_param SCRIPT_FILENAME /opt/nginx/bugzilla/$fastcgi_script_name;
    include /etc/nginx/fastcgi_params;
    # attachments can be huge
    client_max_body_size 0;
    client_body_in_file_only clean;
    # this is where requests body are saved
    client_body_temp_path /opt/nginx/bugzilla/data/request_body 1 2;
}

클라이언트는 약 6000 자 (버그질라 요청)의 URL로 요청을 수행했습니다.

디버깅 중 ...

location ~ ^.*\.cgi$ {
    error_log /var/log/nginx/bugzilla.log debug;
    # ...
}

이것은 내가 로그에서 얻은 것입니다.

2015/03/18 10:24:40 [debug] 4625#0: *2 upstream split a header line in FastCGI records
2015/03/18 10:24:40 [error] 4625#0: *2 upstream sent too big header while reading response header from upstream, client: 10....

"502 bad gateway"대신 "414 request-uri too large"를 사용할 수 있습니까?

그래 넌 할수있어! 나는 "hey the URL 's too long"이라고 생각했기 때문에 이전에 nginx 요청 (오류 코드 : 414, uri 너무 큼)에 대해 허용 된 URL 길이를 설정하는 방법을 읽고 있었지만 502's가 아니라's를 얻었습니다 414.

large_client_header_buffers

# 1 시도 :

# this goes in http or server block... so outside the location block
large_client_header_buffers 4 8k;

이것은 실패하고 내 URL은 6000 자 <8k입니다. # 2 시도 :

large_client_header_buffers 4 4k;

이제는 502 Bad Gateway더 이상 표시되지 않고 대신414 Request-URI Too Large

"FastCGI 레코드에서 헤더 행을 업스트림 분할"

인터넷 어딘가에서 조사하고 발견했습니다.

이것은 나에게 충분했습니다.

location ~ ^.*\.cgi$ {
    # holds request bigger than 4k but < 8k
    fastcgi_buffer_size 8k;
    # getconf PAGESIZE is 4k for me...
    fastcgi_buffers 16 4k;
    # ...
}

I encountered this problem in the past (not using codeigniter but it happens whenever the responses contain a lot of header data) and got used to tweaking the buffers as suggested here, but recently I got bitten by this issue again and the buffers were apparently okay.

Turned out it was spdy's fault which I was using on this particular project and solved by enabling spdy headers compression like this:

spdy_headers_comp 6;

ReferenceURL : https://stackoverflow.com/questions/13894386/upstream-too-big-nginx-codeigniter

반응형