diff -ur nginx-1.7.6/src/http/modules/ngx_http_proxy_module.c nginx-1.7.6.new/src/http/modules/ngx_http_proxy_module.c
--- nginx-1.7.6/src/http/modules/ngx_http_proxy_module.c	2014-09-30 17:20:34.000000000 +0400
+++ nginx-1.7.6.new/src/http/modules/ngx_http_proxy_module.c	2014-10-25 05:58:15.496872443 +0400
@@ -2876,7 +2876,7 @@
     ngx_conf_merge_ptr_value(conf->cookie_paths, prev->cookie_paths, NULL);
 
 #if (NGX_HTTP_SSL)
-    if (conf->upstream.ssl == NULL) {
+    if (conf->upstream.ssl == NULL && conf->upstream.upstream == NULL) {
         conf->upstream.ssl = prev->upstream.ssl;
     }
 #endif
@@ -2905,15 +2905,14 @@
     }
 
     if (conf->upstream.upstream == NULL) {
+        if (conf->proxy_lengths == NULL) {
+            conf->proxy_lengths = prev->proxy_lengths;
+            conf->proxy_values = prev->proxy_values;
+        }
         conf->upstream.upstream = prev->upstream.upstream;
         conf->vars = prev->vars;
     }
 
-    if (conf->proxy_lengths == NULL) {
-        conf->proxy_lengths = prev->proxy_lengths;
-        conf->proxy_values = prev->proxy_values;
-    }
-
     if (conf->upstream.upstream || conf->proxy_lengths) {
         clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
         if (clcf->handler == NULL && clcf->lmt_excpt) {
