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

March 22, 2017 334 views
Apache WordPress Node.js One-Click Install Apps Ubuntu 16.04

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

2 Answers

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

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;
}
Have another answer? Share your knowledge.