Opened 6 years ago

Closed 6 years ago

#1713 closed defect (invalid)

proxy_ssl_session_reuse not working with proxy_pass containing variables

Reported by: gchiesa@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.15.x
Keywords: proxy_module Cc:
uname -a: Linux ip-10-13-61-14.surepay.local 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.15.7
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

Description

Hi,

I'm trying to enable the proxy_ssl_session_reuse with dynamic proxy_pass as per the following config.

server {
    listen       80;
    server_name  localhost;

    ssl_session_cache   shared:SSL:20m;
    ssl_session_timeout 4h;
    proxy_ssl_session_reuse     on;
    proxy_ssl_protocols         TLSv1.2;
    proxy_ssl_ciphers          
EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
    proxy_ssl_server_name       on;
    proxy_socket_keepalive      on;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    set $upstream_server https://myupstream.com;
    location /test/ {
            # forward the request id received in the headers to the
upstream
            proxy_set_header X-Request-Id $http_x_request_id;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_set_header Host "myupstream.com";

            resolver 8.8.8.8;
            rewrite ^/test/(.*) /$1 break;
            proxy_pass $upstream_server;

            # completely disable proxy cache
            expires off;
            sendfile off;

    }

}

but the proxy module does not honor proxy_ssl_session_reuse.

On the other hands in the case of NOT DYNAMIC resolution it works fine. Example:

server {
    listen       80;
    server_name  localhost;

    ssl_session_cache   shared:SSL:20m;
    ssl_session_timeout 4h;
    proxy_ssl_session_reuse     on;
    proxy_ssl_protocols         TLSv1.2;
    proxy_ssl_ciphers          
EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
    proxy_ssl_server_name       on;
    proxy_socket_keepalive      on;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    location /test/ {
            # forward the request id received in the headers to the
upstream
            proxy_set_header X-Request-Id $http_x_request_id;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_set_header Host "myupstream.com";

            resolver 8.8.8.8;
            rewrite ^/test/(.*) /$1 break;
            proxy_pass https://myupstream.com;

            # completely disable proxy cache
            expires off;
            sendfile off;

    }

}

Expected behaviour:
when I use variables in proxy_pass directive all the proxy_ssl* directive are honored (in the same way they are honored with no variables in proxy_pass)

Change History (1)

comment:1 by Maxim Dounin, 6 years ago

Resolution: invalid
Status: newclosed

That's expected behaviour. SSL sessions are cached within a corresponding upstream object, and using variables as in your example implies that the upstream object will be dynamically created for a single request and then destroyed. This effectively prevents SSL session caching from working. For SSL session reuse to work, consider using proxy_pass without variables, or refer to an existing upstream when using variables.

Note: See TracTickets for help on using tickets.