Question

Can I install NodeJs on my subdomain while my droplet was installed with Wordpress configuration ? ( Ubuntu 16.04)

Can I install NodeJs on my subdomain while my droplet was installed with Wordpress configuration ? ( Ubuntu 16.04)

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

If you’re using NGINX you can use this server block.

server {
  listen 80;
  listen [::]:80;

  server_name domain.com sub.domain.com;

location / {
  proxy_pass http://localhost:3000; # nodejs is on the same machine
  # proxy_pass http://192.168.1.1xx:3000; # if on a different machine in the local network.
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Forwarded-Proto $scheme;
}

Yes, you just need to add this as the vhost in apache:

<VirtualHost *:80>
ServerName subdomain.yourdomain.com
ProxyPreserveHost on
ProxyPass / http://localhost:3000/
</VirtualHost>

Expecting that Node is installed and listening on localhost port 3000