Page 1 of 2

[GUIDE]EASY use Nodejs on VESTAcp Ubuntu

Posted: Sat May 05, 2018 5:36 pm
by robert.ne13
first we need to install
aptitude
on console

Code: Select all

sudo apt install aptitude
and put

Code: Select all

aptitude install -y libapache2-mod-proxy-html libxml2-dev
later configure

Code: Select all

sudo a2enmod
and we add the new mods

Code: Select all

proxy proxy_ajp proxy_http rewrite deflate headers proxy_balancer proxy_connect proxy_html
ok now apache is ready to redirect any port from vesta panel to port of nodejs express
Now we have to create a new hosting account
and configure to redirect to nodejs port
open the file

Code: Select all

nano /home/[put user]/conf/web/[web to redirect nodejs ]apache2.httpd.conf
and add this lines:
Behind

Code: Select all

<VirtualHost YOUR.IP:PORT>
ADD

Code: Select all

    ProxyPreserveHost On
    ProxyRequests Off
    ProxyVia Full
and before the end of document

Code: Select all

</VirtualHost>
ADD this:

Code: Select all

<Location /> 
        ProxyPassReverse http://127.0.0.1:3000/
        ProxyPass http://127.0.0.1:3000/ connectiontimeout=5 timeout=30
        </Location>
        
NOTE: my port of nodejs is 3000 modify as yours and if you want to use a folder to redirect to nodejs put this

Code: Select all

<Location /nodejs>
        ProxyPassReverse http://127.0.0.1:3000/
        ProxyPass http://127.0.0.1:3000/ connectiontimeout=5 timeout=30
        </Location>
now the domain of nodejs will be
http://localhost/nodejs/ -> will send you to http://localhost:3000

REMIND to open port on firewall of nodejs

Re: [GUIDE]EASY use Nodejs on VESTAcp Ubuntu

Posted: Sun May 06, 2018 6:00 am
by mehargags
Good guide...
However, Vesta uses Nginx as reverse proxy so wouldn't it be better to configure Nginx to be proxy for your NodeJS straight and not do Nginx > Apache > NodeJS ??

Re: [GUIDE]EASY use Nodejs on VESTAcp Ubuntu

Posted: Sun May 06, 2018 6:51 am
by ScIT
also do not change the conf files in user directory, they get overwritten after a change (for example adding a alias and so on). It is better, to create a nodejs template in /usr/local/vesta/data/templates/web/nginx/, just copy the default template you want to have and do the modification there.

Re: [GUIDE]EASY use Nodejs on VESTAcp Ubuntu

Posted: Sun May 06, 2018 2:35 pm
by mehargags
ScIT wrote:
Sun May 06, 2018 6:51 am
It is better, to create a nodejs template in
Exactly,
That should be the right way forward. Infact, you can submit your template to the dev team and they may include it in official version too

Re: [GUIDE]EASY use Nodejs on VESTAcp Ubuntu

Posted: Wed May 09, 2018 8:13 pm
by robert.ne13
i am a new user of VESTACP i like so much, so i will read some docs of how make a new template and i will make a new one to send

Re: [GUIDE]EASY use Nodejs on VESTAcp Ubuntu

Posted: Thu May 24, 2018 9:02 am
by anxieter
Hello
It is second day I'm trying to intall nodejs to my VestaCP accordingly to your instruction.
I need help.
In the begginning of tutorial you edit apache configuration in

Code: Select all

nano /home/[put user]/conf/web/[web to redirect nodejs ]apache2.httpd.conf
Then it is advised to use templates, but the root given goes to ngnix configuration

Code: Select all

/usr/local/vesta/data/templates/web/nginx/
Was it mastake? I think that root to a template should goes to

Code: Select all

/usr/local/vesta/data/templates/web/apache2/
to modify apache configuration.

If not - what changes should be made in nginx template

Code: Select all

default.tpl

Re: [GUIDE]EASY use Nodejs on VESTAcp Ubuntu

Posted: Thu May 24, 2018 9:03 am
by ScIT
This was a mistake yes, please use the apache folder.

Re: [GUIDE]EASY use Nodejs on VESTAcp Ubuntu

Posted: Thu May 24, 2018 12:55 pm
by anxieter
Can you check if I modified template without errors?

Code: Select all

cd /usr/local/vesta/data/templates/web/apache2# 

Code: Select all

nano default.tpl
http://joxi.ru/8Ana0YktqYY8j2

After editing this I typed

Code: Select all

for user in $(ls /usr/local/vesta/data/users/);do v-rebuild-user $user;done
When I go to site - this configuration makes Service Unavailable error
Maybe I had to point out http://my.external.ip:3000/ ??

Re: [GUIDE]EASY use Nodejs on VESTAcp Ubuntu

Posted: Thu May 24, 2018 5:34 pm
by ScIT
would like that robert.ne13 will answer here, my reply was only about the modification place and not the content itself.

Re: [GUIDE]EASY use Nodejs on VESTAcp Ubuntu

Posted: Fri Jun 22, 2018 8:40 am
by robert.ne13
i recomend to you create a new template for this kind of use but instead of this it seems to be all ok you checked the port was opened and started service ?.