Memory leak in outgoing https connections

Hi!

I believe, there is a memory leak in nginx somewhere in handling
outgoing HTTPS connections. I am using it as a simple http-to-https
proxy. My configuration is the following:

resolver 8.8.8.8;
server {
listen 127.0.0.1:81;
server_name localhost;
access_log off;
location / {
proxy_pass $http_x_proxy_url;
}
}

When I try to run something like:
bash -c “while :; do curl -H ‘X-Proxy-Url: https://any-https-site.tld/
http://localhost:81/; done”

I see nginx eating more and more memory with each request.

I used the latest stable version and compiled it from source on Debian
Lenny x64:
root@debian-amd64:/usr/local/nginx/sbin# ./nginx -V
nginx: nginx version: nginx/1.0.5
nginx: built by gcc 4.3.4 (Debian 4.3.4-6~bpo50+1)
nginx: TLS SNI support enabled
nginx: configure arguments: --with-debug --with-http_stub_status_module
–with-http_flv_module --with-http_ssl_module --with-http_dav_module

Best regards,
Anton.

Posted at Nginx Forum:

Hello!

On Thu, Jul 21, 2011 at 12:44:50PM -0400, knyar wrote:

access_log  off;
location / {
        proxy_pass $http_x_proxy_url;
}

}

When I try to run something like:
bash -c “while :; do curl -H ‘X-Proxy-Url: https://any-https-site.tld/
http://localhost:81/; done”

I see nginx eating more and more memory with each request.

Thank you for report, attached patch fixes the leak.

Workaround is “proxy_ssl_session_reuse off;”.

Maxim D.