0

I am developing a website through HapiJS and I'm configuring SSL. I have already created certificate and private key, and configure the TLS for Hapi server.

The problem is this, the server is started successfully on port 80 (without giving any error) but when I go to "call" the site by browser that does not respond and as a result I: "The web page is not available (ERR_CONNECTION_REFUSED)" If I create (I start) the server on another port, such as port 8080, the site responds properly. For clarity I add the pieces of code that make up the hapi server:



     private server = new Hapi.Server({ debug: { request: ['error'] } });
     this.server.connection({
       port: '0.0.0.0',
       host: 80,
       tls: {
          key: fs.readFileSync(__dirname + "/user_domain_io_key.pem", 'utf8'),
          cert: fs.readFileSync(__dirname + "/user_domain_io_cert.pem", 'utf8')
       }
     });

     this.server.route({
      path: '/login',
      method: 'GET',
      handler: function(request, reply) {
         reply.view('login');
      }
     });

     this.server.start(function () {
      console.log('server running at: ' + that.server.info.uri);
     });

What I do not understand is why the site is not liable if the server start on port 80. Do you have any advice for me? Someone has already dealt with the problem? Thanks.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • What does the console log say? – Stephen Kennedy Jun 20 '15 at 16:41
  • Usually node.js requires some extra configuration on the server environment to be able to run on port 80. See this SO thread: http://stackoverflow.com/questions/6109089/how-do-i-run-node-js-on-port-80 However, you shouldn't be running SSL on port 80. Typically port 80 is reserved for regular traffic and by defualt the SSL port is usually 443 – DrewT Jun 20 '15 at 17:10
  • StephenKennedy one of the problems was just that and that is that the console log reported no error @DrewT Thanks, I did a test using port 443 and all works correctly, starting from some indications of the links that I have reported have also managed to set things up for the 80. – Alessandro Severa Jun 22 '15 at 07:10

1 Answers1

2

Don't you have the port and host parameters reversed?

Shouldn't it be

port: 80

host: '0.0.0.0'