By HoundCoder
I have recently created a NodeJS application and am trying to get a subdomain to point to it. My Digital Ocean DNS is fine and is directing to my server properly. My Apache virtual host is allowing the connection, however it sends back my default document root, not the data that is being served on the specified port. I fear I may be doing it wrong. Could someone provide me with steps on how to make Apache point to a port on my server?
Thanks.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I’m not sure exactly how you went about creating and deploying your app, but take a look at the post I just wrote here: http://markrabey.com/blog/2015/02/08/express-site-with-digital-ocean-and-dokku/ - You may be able to abstract some of the deployment steps to help you out.
A standard A or CNAME record can only direct a subdomain at a name or IP address but cannot specify a port. SRV records will allow you to specify a port but may not be supported in all instances. The best course of action to host a node.js application on a subdomain would be to set it up on a droplet with it’s own IP and point your subdomain to that.
Another option would be configuring Apache to reverse proxy requests to NodeJS. Create a VirtualHost that looks like this:
<VirtualHost *:80>
ServerName node.yourdomain.com
<Location "/">
ProxyPreserveHost On
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
</VirtualHost>
Replace 3000 with the port your nodejs app is listening on and and node.yourdomain.com with the actual domain name you want to serve your nodejs app on.
Then, restart Apache:
sudo service apache2 restart
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.