(해석 또는 이해가 잘못된 부분이 있다면 댓글로 편하게 알려주세요.)
Let’s take a closer look at the subtle problem with keep-alive and dumb proxies. A web client’s Connection: Keep-Alive header is intended to affect just the single TCP link leaving the client. This is why it is named the “connection” header. If the client is talking to a web server, the client sends a Connection: Keep-Alive header to tell the server it wants keep-alive. The server sends a Connection: Keep-Alive header back if it supports keep-alive and doesn’t send it if it doesn’t.
keep-alive와 dumb 프록시의 미묘한 문제에 대해 더 면밀히 살펴보겠습니다.
웹 클라이언트의 Connection: Keep-Alive 헤더는 클라이언트를 떠난 하나의 TCP 링크에만 영향을 미칩니다.
이것의 이름이 "연결" 헤더인 이유입니다.
클라이언트가 웹 서버와 통신하는 중이라면 클라이언트는 Connection: Keep-Alive 헤더를 전달하여 연결을 지속할 의사를 표출합니다.
만약 서버가 지속 연결을 지원할 의사가 있다면 서버는 Connection: Keep-Alive 헤더를 반환하고, 그렇지 않다면 반환하지 않습니다.
The problem comes with proxies—in particular, proxies that don’t understand the Connection header and don’t know that they need to remove the header before proxy- ing it down the chain. Many older or simple proxies act as blind relays, tunneling bytes from one connection to another, without specially processing the Connection header.
문제는 프록시와 함께 발생합니다. 특히 Connection 헤더를 이해하지 못하고 다음 체인으로 내려가기 전에 헤더를 삭제해야 함을 알지 못하는 프록시라면 더욱 그렇습니다.
오래되거나 단순한 프록시들은 대개 Connection 헤더를 특수하게 처리하지 않고 한 연결에서 다른 연결로 바이트를 터널링하는 블라인드 릴레이를 수행합니다.
Imagine a web client talking to a web server through a dumb proxy that is acting as a blind relay. This situation is depicted in Figure 4-15.
블라인드 릴레이로 동작하는 dumb 프록시를 통해 웹 서버와 통신하는 웹 클라이언트를 생각해봅시다.
이 상황은 Figure 4-15에 나타나고 있습니다.
Here’s what’s going on in this figure:
- In Figure 4-15a, a web client sends a message to the proxy, including the Connec- tion: Keep-Alive header, requesting a keep-alive connection if possible. The client waits for a response to learn if its request for a keep-alive channel was granted.
다음은 진행 과정입니다.
- The dumb proxy gets the HTTP request, but it doesn’t understand the Connec- tion header (it just treats it as an extension header). The proxy has no idea what keep-alive is, so it passes the message verbatim down the chain to the server (Figure 4-15b). But the Connection header is a hop-by-hop header; it applies to only a single transport link and shouldn’t be passed down the chain. Bad things are about to happen.
- In Figure 4-15b, the relayed HTTP request arrives at the web server. When the web server receives the proxied Connection: Keep-Alive header, it mistakenly concludes that the proxy (which looks like any other client to the server) wants to speak keep-alive! That’s fine with the web server—it agrees to speak keep- alive and sends a Connection: Keep-Alive response header back in Figure 4-15c. So, at this point, the web server thinks it is speaking keep-alive with the proxy and will adhere to rules of keep-alive. But the proxy doesn’t know the first thing about keep-alive. Uh-oh.
- In Figure 4-15d, the dumb proxy relays the web server’s response message back to the client, passing along the Connection: Keep-Alive header from the web server. The client sees this header and assumes the proxy has agreed to speak keep-alive. So at this point, both the client and server believe they are speaking keep-alive, but the proxy they are talking to doesn’t know anything about keep-alive.
- Because the proxy doesn’t know anything about keep-alive, it reflects all the data it receives back to the client and then waits for the origin server to close the connection. But the origin server will not close the connection, because it believes the proxy explicitly asked the server to keep the connection open. So the proxy will hang waiting for the connection to close.
- When the client gets the response message back in Figure 4-15d, it moves right along to the next request, sending another request to the proxy on the keep-alive connection (see Figure 4-15e). Because the proxy never expects another request on the same connection, the request is ignored and the browser just spins, making no progress.
- This miscommunication causes the browser to hang until the client or server times out the connection and closes it.*
To avoid this kind of proxy miscommunication, modern proxies must never proxy the Connection header or any headers whose names appear inside the Connection values. So if a proxy receives a Connection: Keep-Alive header, it shouldn’t proxy either the Connection header or any headers named Keep-Alive.
이러한 프록시 소통의 오류를 피하기 위해 모던 프록시는 Connection 헤더나 Connection 값에 나타나는 모든 헤더들을 절대 프록시해서는 안 됩니다.
즉, 프록시가 Connection: Keep-Alive 헤더를 받는다면 Connection 헤더나 Keep-Alive로 명명된 임의의 헤더가 프록시 되어서는 안 됩니다.
In addition, there are a few hop-by-hop headers that might not be listed as values of a Connection header, but must not be proxied or served as a cache response either. These include Proxy-Authenticate, Proxy-Connection, Transfer-Encoding, and Upgrade. For more information, refer back to “The Oft-Misunderstood Connection Header.”
추가로 Connection 헤더의 값으로 나열되지 않을 수도 있는 몇 가지 hop-by-hop 헤더가 존재합니다. 하지만 이것이 프록시되거나 캐시 응답으로 제공되어서는 안 됩니다.
이러한 헤더에는 Proxy-Authenticate, Proxy-Connection, Transfer-Encoding, Upgrade가 포함됩니다.
자세한 정보는 "The Oft-Misunderstood Connection Header"를 참고하기 바랍니다.
** https://velog.io/@dvlp-sy/TIL-HTTP-The-Definitive-Guide-p86-p88
오늘도... 고봉밥 텍스트를 소화하기 힘들었습니다. 화요일은 특히 바쁜 날이라, 목표한 분량을 끝까지 읽어낸 것에 의의를 두겠습니다.
Dumb 프록시가 고유명사인지 일종의 비유 표현인지는 잘 모르겠습니다. 한국말로 직역하면 '멍청한 프록시'인데 그건 좀 아닌 것 같아서 그냥 영어 표현을 그대로 사용했습니다 ㅎ... 실제로 멍청한 프록시를 지칭하는 게 맞습니다만 이게 고유명사가 되는 건 느낌이 좀 다릅니다. 사대주읜가
어쨌든 Connection 헤더를 사용하는 Keep-alive 연결이 일부 프록시에서 문제를 일으킬 수 있다는 사실을 알게 되었습니다. 만약 Keep-alive 연결을 사용해야 할 일이 있다면 이 점에 유의하는 것이 좋겠습니다.