Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7508783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:44:19+00:00 2026-05-29T22:44:19+00:00

I’m using one server to host multiple Node.js web apps, which are distributed across

  • 0

I’m using one server to host multiple Node.js web apps, which are distributed across multiple domains. My current practice is to run an Express server for each app on a different port, and to run a base server that simply routes (redirects) requests to the correct port/Express server. This works, but it means that my base server is routing every single HTTP request (and by manually redirecting it), and that my users see my apps as hosted at [hostname.com]:8000.

After a bit of research, I’ve found that I can use http-proxy for my routing needs, but I’d still like to know if there’s a best practice for running multiple Express servers on the same system. Here’s how I’m planning on doing it:

Each web app will have its own folder, with a complete Express folder structure (app.js, routes, views, etc.) Apps will be grouped by domain, so an example folder structure would be:

    hostname.com/
        app.js
        routes/
        views/
        ...
        app1/
            app1.js
            routes/
            views/
            ...
        app2
        ...
    hostname2.com/
        app.js
        routes/
        views/
        ...

I’ll have to run each app.js separately with node (or with forever, which I’m currently using), and each one will have to use a different port internally, with cross-app redirects being pointed at the port of the target app.

So, that’s my current plan. What are the problems with it, and what pitfalls should I try to avoid?
Most importantly, is there an established solution to this problem – the problem of hosting multiple web apps on the same system with Node.js/Express?

EDIT: I do plan to eventually use WebSockets and HTTPS, and the amount of bandwidth my setup can support is of little importance to me – this is a development server (at least for now). Thanks to David Ellis for bringing up the issue of WebSockets.

SECOND EDIT: Thanks to both EhevuTov and David Ellis for their answers, both of which helped greatly. I’m still settling on an overall structure for my application, and it looks like that question is addressed in some detail by this StackOverflow question

THIRD EDIT: I’ve come a ways since posting this question (though I have much further to go). Check out this file in my GitHub repository, which leverages what I learned from the answers to this question!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:44:19+00:00Added an answer on May 29, 2026 at 10:44 pm

    Since Express uses Connect, I’m pretty sure you can use Connect’s virtual host middleware. It operates similar to other vhost modules on other products. I don’t have multiple domains to test and show you proper code, but I would think it’s something like this:

    express.createServer()
    .use(express.vhost('hostname1.com', require('/path/to/hostname1').app)
    .use(express.vhost('hostname2.com', require('/path/to/hostname2').app)
    .listen(80)
    

    If you get to the point where one Express server isn’t enough, then look into using the Node.Cluster from the API. If that also isn’t enough, then the current practice is to put a asnyc reverse proxy such as Nginx in front of your Express servers and point the proxies to your Express servers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.