Node.js website hosting

Discussion in 'General' started by Sharone, Jul 30, 2020.

Tags:
  1. Sharone

    Sharone Member

    Hi there,

    I am running ISPConfig 3.1.5p3 on Ubuntu 18.04, multiserver setup. I would like advice on hosting one of the customers whose website uses Node.js. All the files and folders have been uploaded to the web server (slave) and the index.js file exists. index.html has been moved. Attached is what the website appears as so far

    Permissions
    Code:
    root@web:/var/www/clients/client275/web105/web# ll
    total 60
    drwxr-xr-x  9 web105 client275 4096 Jul 30 14:18 ./
    drwxr-xr-x 10 root   root      4096 Jul 27 13:24 ../
    drwxr-xr-x  2 web105 client275 4096 Jul 27 13:24 error/
    -rwxr-xr-x  1 web105 client275 7358 Jul 27 13:24 favicon.ico*
    -rwxr-xr-x  1 web105 client275 6968 Mar 12 17:16 index.js*
    drwxr-xr-x  2 web105 client275 4096 Jul 29 12:19 models/
    drwxr-xr-x  6 web105 client275 4096 Jul 29 12:19 public/
    -rwxr-xr-x  1 web105 client275   14 Jul 27 13:24 robots.txt*
    drwxr-xr-x  2 web105 client275 4096 Jul 29 12:19 routes/
    drwxr-xr-x  2 web105 client275 4096 Jul 27 17:33 stats/
    drwxr-xr-x  2 web105 client275 4096 Jul 29 12:19 uploads/
    drwxr-xr-x  2 web105 client275 4096 Jul 29 12:19 views/
    Code:
    root@web:/var/www/clients/client275/web105# ll
    total 40
    drwxr-xr-x 10 root   root      4096 Jul 27 13:24 ./
    drwxr-xr-x  3 root   root      4096 Jul 27 13:24 ../
    drwxr-xr-x  2 web105 client275 4096 Jul 27 13:24 cgi-bin/
    drwxr-xr-x  2 root   root      4096 Jul 30 00:18 log/
    drwx--x---  2 web105 client275 4096 Jul 27 13:24 private/
    drwx------  2 web105 client275 4096 Jul 27 13:24 .ssh/
    drwxr-xr-x  2 root   root      4096 Jul 27 13:24 ssl/
    drwxrwx---  2 web105 client275 4096 Jul 27 13:24 tmp/
    drwxr-xr-x  9 web105 client275 4096 Jul 30 14:18 web/
    drwx--x---  2 web105 client275 4096 Jul 27 13:24 webdav/
    
     

    Attached Files:

  2. Sharone

    Sharone Member

    Hi,
    Kindly requesting for a tutorial (ISPConfig) to get a website that uses NodeJS running on a slave server. I've installed nodejs,npm, forever and pm2 as well as added this code to the Apache directives on the ISPConfig portal
    Code:
    ProxyRequests Off
    ProxyPreserveHost on
    ProxyPass / http:// localhost:8080
    ProxyPassReverse / http:// localhost:8080
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    I could use some guidance
     
  3. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

  4. Sharone

    Sharone Member

    Thank you for your response. I have removed the apache directives and edited jailkit as instructed but still get the same thing. I may have missed something prior to this but I cannot tell what it is
     
  5. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    dunno, on the sites i'm hosting, i don't think any .js files are being called directly by apache, the starting point is still php files.
    maybe setting
    Code:
    DirectoryIndex index.js index.php index.html
    as an apache directive or in .htaccess

    i would also suggest turning off the indexes option in /etc/apache2/apache2.conf:
    Code:
    <Directory /var/www/>
            Options -Indexes +FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>
    
    so that any visitors connecting to the site can't see the list of files that exist if a folder doesn't contain an index file that apache is running.
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    I've never used node.js, but as far as I know, it has it's own service to run js scripts on the server-side, so the js scripts don't get interpreted by Apache. It is likely that you must use proxying as you did in your first implementation attempt.
     
  7. madmucho

    madmucho Member

    One of my customer using nodejs part of project for websocket implementation (CMS Article locking in realtime) server debian buster so i can share my setting.

    For nodejs itself i made system.d unit file so it act like service, loging to syslog, but docker principe is also applicable, incrontab to restart service if customer uploads new index.js.
    From ispconfig side i make domain and proxy its trafic to internal localhost port, page itself have ssl and LE enabled and is maintained from ispconfig side.
    Works ok.

    Web Domain > Options tab > Apache Directives
    Code:
    SSLProxyEngine On
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off
    
    RewriteEngine On
    RewriteCond %{REQUEST_URI}  ^/socket.io [NC]
    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*)           ws://localhost:3001/$1 [P,L]
    
    ProxyPass /.well-known/ !
    ProxyPass / http://localhost:3001/
    ProxyPassReverse / http://localhost:3001/
    for websocket on apache specificly you need proxy module enabled in debian to correctly handle websocket requests.
    Code:
    a2enmod proxy_wstunnel
    Hope this helps
     
    Jesse Norell likes this.

Share This Page