Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NodeJs SSL on Gandi Simple Hosting: listen EACCES

Tags:

node.js

ssl

I am pretty desperate, the following problem is haunting me for weeks now: I am encountering the "listen EACCES" error on my Gandi Simple Hosting instance, when i try to run my NodeJs instance on port 443. Is there something i did wrong i didn't know about? I must say that I'm very new to the whole hosting topic.

I am using NodeJs with Express, here's the relevant code:

var express = require('express')
  , https = require('https');
var fs = require('fs');

var options = {
    key: fs.readFileSync('./scrt/apiKey.key'),
    cert: fs.readFileSync('./scrt/apiCrt.crt')
};
//....
app.set('port', process.env.PORT || 443);
//.....
https.createServer(options, app).listen(app.get('port'), function(){
});

Do you have any idea what i miss? Maybe i have to change some configuration for the port 443? I was just told by Gandi, that port 443 is the right port for SSL, so actually it should work...

Thank you very much in advance for your help!

Edit: No one here ever had the same problems with SSL on nodejs? :/

like image 659
superHH Avatar asked Feb 12 '26 05:02

superHH


2 Answers

In Gandi Simple Hosting, SSL is done by a SSL offloader, you do not need to handle it by yourself.

The ssl offloader then redirects all incoming trafic (HTTP and HTTPS) on the instance's 8080 port.

To see if a request is secure, I bet you could look at the X-Forwarded-Proto header.

like image 163
themouette Avatar answered Feb 14 '26 18:02

themouette


Ok I have had the answer from Gandi support team: all the traffic, SSL and not SSL is routed to the port 8080.

I still could not get it working since nodejs needs to handle one port for both traffic and it is not straightforward, see these posts

  • Is possible to run http and https server with same port no in node.js using express?
  • A node.js proxy that accepts HTTP and HTTPS traffic on the same port.

EDIT: @themouette is right, it works out of the box, no need to handle it in nodejs, but you need to activate the certificate on the domain level, but from your instance's admin page, which is not written in the docs.

like image 27
lexa Avatar answered Feb 14 '26 19:02

lexa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!