0

I am building a website, where the landing page and some other content is based on node, express, angular2 etc.

I want to have a subdomain (blog.mydomain.com) which runs Hexo. On my development machine, I run hexo server to test the blog on localhost:4000. I can deploy to heroku by running hexo generate -deploy. So I have two questions - if I had a node app, where one of the sub-directories contained my current hexo project, how would I deploy it, as if I just uploaded the content, what would trigger hexo to run?

Secondly, how to I route from my main app, to the blog? I have seen a number of suggestions to use vhost with express. Would I run the two servers through different ports, and then just route /blog routes to0.0.0.0:4000 for example?

1

You'll need to run both node apps on different ports, I suggest using PM2, which is a free and popular tool.
Then you'll need to route from the different domains or folder to different ports.
NGINX is a very powerful tool, yet using apache is much easier to configure and will do what you need.

Here's how you might want to set your routing:
www.example.com:80 >> localhost:80
blog.example.com:80 >> localhost:4000
OR
www.example.com >> localhost:80
www.example.com\blog >> localhost:4000

  • Thanks so much - that's really helpful. What does PM2 do? – George Edwards Aug 6 '16 at 19:16
  • PM2 lets you run multiple node processes in the background, keep them alive, monitor them, etc... – Ronen Teva Aug 6 '16 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.