1

This works, tested by going to https://sensorypanel.net:

var fs = require('fs');

var http = require('http');
http.createServer(function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
}).listen(80, '0.0.0.0');

var https = require('https');
var options = {
    key: fs.readFileSync('certs/sensorypanel.net/sensorypanel_net-key.pem'),
    cert: fs.readFileSync('certs/sensorypanel.net/sensorypanel_net.crt'),
    ca: fs.readFileSync('certs/ca_bundle.crt')
};
https.createServer(options, function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello SSL World\n');
}).listen(443, '0.0.0.0');

But using Redbird as a reverse proxy, this doesn't work:

var redbird = require('redbird'),
    http = require('http');

var proxy = redbird({
    port: 80,
    ssl: {
            port: 443,
            key: 'certs/sensorypanel.net/sensorypanel_net-key.pem',
            cert: 'certs/sensorypanel.net/sensorypanel_net.crt',
            ca: 'certs/ca_bundle.crt'
    }
});

proxy.register('sensorypanel.net', 'http://localhost:4001', {ssl: true});

http.createServer(function(req, res) {
    console.log('Got a request!');
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
}).listen(4001, '0.0.0.0');

The connection isn't refused immediately. It just hangs. I can still go around the proxy via http://sensorypanel.net:4001, which verifies the underlying HTTP service is working. The firewall is off.

Here's a sample of the log:

{"name":"redbird","hostname":"sensorypanel.net","pid":1370,"level":30,"msg":"Listening to HTTPS requests on port 443","time":"2015-08-26T04:46:05.919Z","v":0}
{"name":"redbird","hostname":"sensorypanel.net","pid":1370,"level":30,"msg":"80 'Started a Redbird reverse proxy server'","time":"2015-08-26T04:46:05.925Z","v":0}
{"name":"redbird","hostname":"sensorypanel.net","pid":1370,"level":30,"from":    {"protocol":"http:","slashes":true,"auth":null,"host":"sensorypanel.net","port":null,"hostname":"sensorypanel.net","hash":null,"search":null,"query":null,"pathname":"/","path":"/","href":"http://sensorypanel.net/"},"to":    {"protocol":"http:","slashes":true,"auth":null,"host":"localhost:4001","port":"4001","hostname":"localhost","hash":null,"search":null,"query":null,"pathname":"/","path":"/","href":"http://localhost:4001/","sslRedirect":true,"useTargetHostHeader":false},"msg":"Registered a new route","time":"2015-08-26T04:46:05.931Z","v":0}
{"name":"redbird","hostname":"sensorypanel.net","pid":1370,"level":50,"err":{"message":"socket hang up","name":"Error","stack":"Error: socket hang up\n    at TLSSocket.<anonymous> (_tls_wrap.js:664:25)\n    at TLSSocket.emit (events.js:107:17)\n    at TCP.close (net.js:485:12)","code":"ECONNRESET"},"msg":"HTTPS Client  Error","time":"2015-08-26T04:46:27.847Z","v":0}
{"name":"redbird","hostname":"sensorypanel.net","pid":1370,"level":50,"err":{"message":"socket hang up","name":"Error","stack":"Error: socket hang up\n    at TLSSocket.<anonymous> (_tls_wrap.js:664:25)\n    at TLSSocket.emit (events.js:107:17)\n    at TCP.close (net.js:485:12)","code":"ECONNRESET"},"msg":"HTTPS Client  Error","time":"2015-08-26T04:46:41.931Z","v":0}
Steve
  • 8,066
  • 11
  • 70
  • 112
  • Did you manage to solve this? – inf3rno Feb 25 '16 at 06:31
  • No, I ended up using nginx. – Steve Feb 26 '16 at 09:10
  • Did you send a bug report? https://github.com/OptimalBits/redbird/issues – inf3rno Feb 26 '16 at 09:14
  • No I didn't file a bug report. – Steve Feb 26 '16 at 09:17
  • Maybe you should. If this is really a bug, the developers should be aware of it. If it isn't a bug, then they can tell you how to use the API. – inf3rno Feb 26 '16 at 09:19
  • It's ancient history. – Steve Feb 26 '16 at 09:21
  • If you don't mind, I'll ask whether this was fixed. I'd like to use redbird instead of nginx if it is production ready. – inf3rno Feb 26 '16 at 09:40
  • I found the same issue: https://github.com/OptimalBits/redbird/issues/25 it was fixed here: https://github.com/OptimalBits/redbird/commit/5c0869594ad6dddacb055a6b6d9db9cbb0d67d96 on 2015 october. You already sent a report: https://github.com/OptimalBits/redbird/issues/17 This can be deleted or closed. – inf3rno Feb 26 '16 at 09:48
  • 1
    @inf3rno feel free to answer this question, indicating that the issue is resolved. Someone may be using an old version and it would be helpful in that case to provide a solution rather than delete the question. – Steve Feb 26 '16 at 10:04

1 Answers1

2

This was a bug in redbird reported here and here. It was caused by a change in some node.js API and it was fixed in this commit on 2015 Oct 27. If you have the same problem, you should upgrade your redbird to a newer version.

inf3rno
  • 24,976
  • 11
  • 115
  • 197