X-Accel-Buffering: no
응답 헤더를 내려주면 SSE 커넥션만 버퍼링 방지.@RequestMapping("/sseExamples") public SseEmitter getRealTimeJudgeResultAction(HttpServletResponse response) throws IOException { // .... response.addHeader("X-Accel-Buffering", "no"); SseEmitter sseEmitter = new SseEmitter(); // .... sseEmitter.send("Established"); return sseEmitter; }
# 응답 결과를 보면 X-Accel-Buffering: no 헤더가 출력됨. curl -D - http://.... HTTP/1.1 200 X-Accel-Buffering: no Content-Type: text/event-stream Transfer-Encoding: chunked ...
proxy_buffering off;
및 기타 설정.location /path/to/sse { proxy_pass http://upstream; proxy_buffering off; # X-Accel-Buffering: no 와 같은 효과 proxy_cache off; proxy_set_header Host $host; proxy_set_header Connection ''; proxy_http_version 1.1; chunked_transfer_encoding off; }