diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js
index d5323968e74dddfff2a1c79a9dd5f7e74764ca23..52cb0ff7cc34684301e54712d691ee67daa6d952 100644
--- a/lib/http-proxy/common.js
+++ b/lib/http-proxy/common.js
@@ -53,7 +53,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
   if (!outgoing.agent) {
     outgoing.headers = outgoing.headers || {};
     if (typeof outgoing.headers.connection !== 'string'
-        || outgoing.headers.connection.toLowerCase() !== 'upgrade'
+        || ! /(^|,)\s*upgrade\s*($|,)/i.test(outgoing.headers.connection)
        ) { outgoing.headers.connection = 'close'; }
   }
 
diff --git a/test/lib-http-proxy-common-test.js b/test/lib-http-proxy-common-test.js
index 98313ff79e4d413714962b8861b167e254e93946..01af2f7ef1ddfa90b3452936c092595d32f23700 100644
--- a/test/lib-http-proxy-common-test.js
+++ b/test/lib-http-proxy-common-test.js
@@ -59,6 +59,49 @@ describe('lib/http-proxy/common.js', function () {
       expect(outgoing.headers.connection).to.eql('upgrade');
     });
 
+    it('should not override agentless connection: contains upgrade', function () {
+      var outgoing = {};
+      common.setupOutgoing(outgoing,
+        {
+          agent: undefined,
+          target: {
+            host      : 'hey',
+            hostname  : 'how',
+            socketPath: 'are',
+            port      : 'you',
+          },
+          headers: {'connection': 'keep-alive, upgrade'}, // this is what Firefox sets
+        },
+        {
+          method    : 'i',
+          url      : 'am',
+          headers   : {'pro':'xy','overwritten':false}
+        });
+      expect(outgoing.headers.connection).to.eql('keep-alive, upgrade');
+    });
+
+    it('should override agentless connection: contains improper upgrade', function () {
+      // sanity check on upgrade regex
+      var outgoing = {};
+      common.setupOutgoing(outgoing,
+        {
+          agent: undefined,
+          target: {
+            host      : 'hey',
+            hostname  : 'how',
+            socketPath: 'are',
+            port      : 'you',
+          },
+          headers: {'connection': 'keep-alive, not upgrade'},
+        },
+        {
+          method    : 'i',
+          url      : 'am',
+          headers   : {'pro':'xy','overwritten':false}
+        });
+      expect(outgoing.headers.connection).to.eql('close');
+    });
+
     it('should override agentless non-upgrade header to close', function () {
       var outgoing = {};
       common.setupOutgoing(outgoing,