NodeJS with ISPconfig3

Discussion in 'Tips/Tricks/Mods' started by Poliman, Mar 11, 2016.

  1. Poliman

    Poliman Member

    I would like to install NodeJS on the server on which is ISPconfg3 installed. After this I would like to configure this with ISPconfig3 - redirecting (specific element of - etherpad editor, which use nodejs) customer's site to nodejs. Site will be created by ISPconfig3, then files will be uploaded via ftp on server. On my server ISPconfig3 cooperate with apache. Should I install nodejs as newly created user each time when I setup new website for user?
    Generally - how to add nodejs to a server managed by ISPCFG3 and then redirect a specific customer's site to node.js (the server is using apache).
  2. Well-Known Member HowtoForge Supporter

    You would need to enable mod_proxy on apache

    a2enmod proxy proxy_http
    service apache2 restart
    Centos change your httpd.conf and uncomment
    LoadModule proxy_module modules/
    LoadModule proxy_http_module modules/

    Do the following settings to your proxy.conf in modules folder
    ProxyRequests Off
    You can then add the following line as example to any websites additional http options field:

    ProxyPreserveHost On
    ProxyPass /node
    Finally run your node.js server like
    var http = require('http');
    http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello Apache!\n'); 
    }).listen(8000, '');
    If you need multiple node.js instances depends on what you're going to do / allow node.js to do - not my topic.
    But you could implement vhost like behaviour if you need to.
    switch( { 
    case '': 
    res.write('<h1>Welcome to</h1>'); 
    case '': 
    res.write('<h1>This is not</h1>');
    res.statusCode = 404; res.write('<p>We do not serve the host: <b>' + + '</b>.</p>'); 
    } res.end();
    Good luck.
    Oh and if you need the real IP beeing passed trough:
    Enable mod_remoteip ( adopt the how to from above ) And add the following to the http options for your website
    RemoteIPHeader X-Forwarded-For
    ahrasis, till and Jesse Norell like this.
  3. suther

    suther Member

    Thank you for sharing this little HowTo. Would love to have a way to create such nodejs support via ISPConfig.
    Is such a feature planed?
    Seems there are only need a few steps to implement it into iscponfig:
    1. Cerate a Section in ispconfig to allow permitted Users (Permission by choosen Customer-Plan) to create 1 node instance
    2. A config-area for Customers with following fields:
      - A switch to choose, if run nodejs at Standalone (Port 80 via Proxypath Setting in Vhost), or unpreveliged Port.
      - [if choosen unpreveliged Port]: to reserve choosen node-port or suggest another one if port still in use
      - a field to enter the node.js Filename to be able to start, monitor and stop the process via ispconfig
    May this be possible, or does i miss some 'make it impossible' arguments?
  4. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    Managing node.js servers like that would be pretty similar to how php-fpm or hhvm daemons are handled now. Of course there would be some differences to work out, but same architecture, I believe. After putting thoughts together on that, you might file a feature request in gitlab.
  5. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

  6. Sowndharraj D

    Sowndharraj D New Member

    Good Day,In which file i have to add this code?
  7. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    from ztk message:
  8. atmomin2003

    atmomin2003 New Member

    I have installed nodejs and have a working website, the apache directive in the options didn't work.
    I have put .htaccess file with below content in web folder of the website where default index.html file is.
    PORT_NUMBER is the listening port of the node app.

    RewriteEngine On
    RewriteRule ^$ [P,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$$1 [P,L]

    I have also installed postgresql to use with nodejs app. Installed pgadmin4 to manage pgsql separately. the setup works perfectly fine.
    I hope this helps others.
    till and ahrasis like this.

Share This Page