ISPConfig 3 running Nginx and Nodejs?

Discussion in 'Tips/Tricks/Mods' started by GreggRed010, Mar 24, 2020.

  1. GreggRed010

    GreggRed010 New Member

    I'm looking for some information and insight into running Nodejs on my ISPConfig server running Nginx. I have multiple sites currently running from the server and I am in need of deploying a new Nuxt.js application.

    Firstly, will this be possible? If so what will I have to do in order to get it working correctly.

    Secondly will it be possible to run multiple apps and sites using node.js, simultaneously? I believe I'd have to do a reverse proxy but honestly I'm unsure.

    Any help and guidance on this matter will be greatly appreciated.
     
  2. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    I don't know about nginx, never really used it. but multiple websites running nodejs shouldn't be a problem. doing that with ispconfig on apache with no problems.

    I just install composer, nodejs and npm as root using apt, (everyone wanting nodejs/npm so far has always wanted composer as well) and make them available in jailkit. so ssh users can use them however they want.

    add to /etc/jailkit/jk_init.ini
    Code:
    [node]
    comment = NodeJS
    executables = /usr/bin/npm, /usr/bin/node, /usr/bin/nodejs, /usr/local/bin/elmi-to-json
    directories = /usr/share/npm, /usr/lib/nodejs, /usr/local/lib/node_modules
    
    
    [composer]
    comment = composer
    executables = /usr/bin/composer
    directories = /usr/share/doc/composer
    
    then just add composer and nodejs to the jailkit app list in the ispconfig server config area, and create the ssh user or update existing jailkit.

    I've never had to do anything with apache to allow any nodejs/npm stuff to work, but as I've already said, I don't know anything about nginx, so someone else will have to say if anything needs to be done there.
     
    ahrasis and GreggRed010 like this.
  3. GreggRed010

    GreggRed010 New Member

    Great Stuff, thank you for the detailed reply and information. Finally getting around to implementing this on my server, so fingers crossed its as straight forward on nginx as it is on apache.
     
    ahrasis likes this.
  4. celocore

    celocore New Member

    Hello,
    I followed these steps and now I have the problem that I get the following error message when I do an "npm -v" in the jailed environment.

    internal/modules/cjs/loader.js:638
    throw err;
    ^

    Error: Cannot find module 'semver'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/usr/share/npm/lib/utils/unsupported.js:2:14)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)


    I'm running ubuntu 20.04 and my jk_init section looks as follows
    Code:
    [node]
    comment = NodeJS
    executables = /usr/bin/npm, /usr/bin/node, /usr/bin/nodejs, /usr/bin/semver
    directories = /usr/share/npm, /usr/share/nodejs, /usr/share/node-mime, /usr/lib/nodejs
    
     
  5. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    yeah, i've noticed the same thing on 20.04 and using ispconfig 3.2.*
    not sure if it's any changes in nodejs/npm packages and file/folder locations, or any differences in the newer jailkit init config.

    not got anyone actively using npm at the moment and i've got other things i need to work on, so trying to work out this issue hasn't been a priority for me.
     
  6. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Seeing the same problem here: Error: Cannot find module 'semver'

    Has anyone found a solution?
     
  7. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    not anything that i've had a chance to try yet.
    everything i've looked at suggests uninstalling / purging node and npm and re-installing..
     
  8. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    I have spend quite some time looking into this today. This seems to work, but I have not got it to work fully:
    - move /usr/share/nodejs/npm/node_modules/* to /usr/local/lib/node_modules/
    - symlink /usr/share/nodejs/npm/node_modules to /usr/local/lib/node_modules
    - jk_update, then jk_init the jail

    But now I am looking at another error, I suspect because the NPM version in the Debian repo is out-of-date, but I'm not sure...
     
    ahrasis likes this.
  9. renky

    renky New Member

    till, Th0m and ahrasis like this.
  10. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Thanks for sharing!
     
  11. Alex Mamatuik

    Alex Mamatuik Member

    My man, why does it important to put Composer and NodeJS to the JailKit?
     
  12. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Those sections now exist by default in the jailkit init file, but are not added to the jails by default. They are needed if you want to use them from a jail of course.
     
  13. Alex Mamatuik

    Alex Mamatuik Member

    Dear Thom, could you recommend me some decent literature about Jails:D?

    As we know, i am originally russian... and it's much actual for the country at the moment
     
  14. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    What do you want to know about it?
     
  15. Alex Mamatuik

    Alex Mamatuik Member

    About the concept of this jailing; i would know how it works
     
  16. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

  17. Alex Mamatuik

    Alex Mamatuik Member

    Okay, just original documentation...

    As i see, for my user, which belongs to the website, was created jk_lsh.ini at /var/www/websites/client0/domain1/etc/jailkit

    But inside of it everything is commented-out:
    Code:
    ## example for a user
    #[test]
    #paths= /usr/lib/
    #executables= /usr/lib/sftp-server
    #allow_word_expansion = 0
    #umask = 002
    #
    ##example for a group, there should be only 1 space inbetween the words!
    #[group users]
    #paths = /usr/bin
    #executables = /usr/bin/cvs
    #allow_word_expansion = 0
    #environment= HELIX_PATH=/opt/RealPlayer/, TMP=/tmp/
    And have you noticed, subdomains are invisible to a user, which was placed to Chroot Shell - Jailkit?

    and chroot() is just the procedure or function - written on C and enabled to all unix-like systems - to change root directory, nothing else, am i right?

    - we change a default directory and make limitations to the used services

    Can you help me with that?

    Do you think, it depends on the jail or not?
     

Share This Page