Why $scheme in proxy_pass url does not work

Hi, I’m wondering why $scheme in proxy_pass url does not work?
Using nginx 0.6.24

The following does not work and results in BAD gateway error

location ~ ^/~ {
proxy_pass $scheme://user-web.zopa.org;
include /etc/nginx/proxy.conf;
break;
}
include /etc/nginx/php.conf;
rewrite ^/(.+)$ /index.php last;

While the following works ok

location ~ ^/~ {
if ($scheme = http) {
proxy_pass http://user-web.zopa.org;
}
if ($scheme = https) {
proxy_pass https://user-web.zopa.org;
}
include /etc/nginx/proxy.conf;
break;
}
include /etc/nginx/php.conf;
rewrite ^/(.+)$ /index.php last;