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 6186741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:56:26+00:00 2026-05-24T01:56:26+00:00

I have two apps. which current run in two different ports. script1.js: var express

  • 0

I have two apps. which current run in two different ports.

script1.js:

var express = require('express'),
    app = require('express').createServer(

         express.cookieParser(),
          // Parses x-www-form-urlencoded request bodies (and json)
          express.bodyParser()  
    )
    ;

app.get('/s1/output', function(sReq, sRes){
    // set cookie

    sRes.send('<div>Out from 1!</div>');
});

app.listen(3000);

and here is script2.js

var express = require('express'),
    app = require('express').createServer(

         express.cookieParser(),
          // Parses x-www-form-urlencoded request bodies (and json)
          express.bodyParser()  
    )
    ;

app.get('/s2/output', function(sReq, sRes){
    // set cookie

    sRes.send('<div>Out from 2!</div>');
});
app.listen(3001);

ok.. it runs separately on two different ports and have no problem.

Now. the story is that, I can only use port 80 for production. System Admin doesn’t want to open 3000 nor other ports.

Instead of merging code. (in fact, my real code is a lot. and have different config settings for script1 and script2), what can I do to make both of them on port 80? but calling /s1/output will go to script1, and /s2/output will go to script2?

I am thinking about having another scripts. script80.js that runs on port 80.
and it require both script1, and script2.

But, the question is, what should I export from script 1 and script2? should I:

define all get / post methods, and then, 
module.exports.app =app?

and in script80.js, should I do soemthing like that:

app.get('/s1/*', function (res, req)) {
   // and what do now?  app1(res) ?
}

mmmm

  • 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-24T01:56:27+00:00Added an answer on May 24, 2026 at 1:56 am

    If you have domains or subdomains pointing to this server, you can also use the vhost middleware:

    app.use(express.vhost('s1.domain.com', require('s1').app));
    app.use(express.vhost('s2.domain.com', require('s2').app));
    
    app.listen(80);
    

    Complete example: https://github.com/expressjs/express/blob/master/examples/vhost/index.js

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

Sidebar

Related Questions

I have two separate apps (one is classic asp, the other is asp.net) which,
i have two iphone apps and want to they able to switch via a
I have a project with two silverlight apps (foo1 and foo2) and an ASP.NET
I have to pass parameters between two rails apps. In one side (sender) I
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
Localizable strings file which are used for Apple/iPhone apps localization have the following format:
I have two applications communicating via RMI, a slave server (of which there will
I have two cocoa-touch apps in one Xcode project. Xcode gives me iPhone/iPad related
I have two web application which are deployed in the same J2EE Application server.
I have an app sits on machine A (solaris.example.com) and same apps sits on

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.