Question

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

Posted March 22, 2017 2.6k views
ApacheNode.jsWordPressOne-Click Install AppsUbuntu 16.04

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

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.

×
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;
}
Submit an Answer