Use 2 URL for different parts of the same app

Hi,
I need advice on how to setup my app.

Basic idea : I want my app accessible by 2 different URL :

  • domainA .com, my main url which point to my root page
  • domainB .com, which points to another page of my app : domainA.com/pageB

I don’t have any database issue, since my database can be shared between the two apps.

My setup now is
domainA -> AWS ELB -> 1 Instance AWS
and I use MUP to deploy, so no NGINX special configuration for now.

Ideally the user browsing with domainB .com won’t see the redirection to domainA .com

Is there any solution which can allow me to keep a single instance (and ideally still use MUP), and not having to use 2 instance and duplicate my app ?

Thanks !

What about other URLs?
Will domainB.com/this/url will be the same as domainA.com/pageB/this/url?
Will all URLs in domainB be the same as domainA.com with a prefix (pageB)?
Or only the first page is different and than other URLs are the same?

I am open to all suggestion in oder to keep it simple

I don’t mind re-defining all my pages in the rooter, and I don’t mind have all my domainB.com/this/url to be the same as domainA.com/pageB/this/url

For the simplest answer (just change the home of domainb.com, other urls are the same) I manage to do it like this with iron-router (add domainb.com to your /etc/hosts for testing):

Router.route('/', function () {
    let hostname = window.location.hostname;
    if (hostname === 'domainb.com') {
      this.render('pageb');
    } else {
      this.render('home');
    }
  },
  {
    name: 'home',
    waitOn: function () {
      if (window.location.hostname === 'domainb.com') {
        return [
          Meteor.subscribe('pageb_publish_1'),
          Meteor.subscribe('pageb_publish_2')
        ];
      }
      return [
        Meteor.subscribe('home_publish_1'),
        Meteor.subscribe('home_publish_2')
      ];
    }
  }
);

Hi,
Thanks for your reply

I can understand your comment about the router part.

But I still can’t figure what happens when the user connect with the domain name.
For now, my domainA DNS points to my loadbalancer, which points to the IP of my server.
In this process, the URL domainB.com get transformed into domainA.com

Which part of my setup does this transformation ? is it a configuration of MUP ?

I have a similar question!
But my case is a bit different: I want to serve same app from different domains. The diff is app language.

  • app.com sd open the app in english and show US data
  • and app.fr sd open the app in french and show France data

But app logic, user accounts, everything else is the same bw the domains.

That possible?

For the record, here is the solution I found

I deploy twice my application on the same EC2 instance, with a different mup configuration : same database, but two different names, two url and to different ports (on on the default port, and one on the 3002 port)

I then use 2 different Load Balancing : both points to the same instance, but one on port 80 and one on port 3002. Each of my domain name points to one of the two Load Balancing

On my app I use bordalix 's solution to test on the router the url used by the user to redirect him to the correct modules.

I don’t know if it is the best solution for you, but it could work I think.

1 Like

offtopic: didn’t have a chance to work wit load balancing. what technology you use for it?

All my technologies are aws:
Instances for app and database are ec2
Load balancing are ELB
dns is Route 53

I use the ELB because it allows me to use natively a ssl certificate. I don’t use any other ELB feature (it only points to one instance, so no real load balancing actually)