I am developing an E-learning platform and have decided it will be best to split the site into three sections (each with its own meteor application). The three sections being:
According to iron-router Issue 223 there is no option for subdomain routing so I won't be able to have a common routes file serving all three subdomains.
Also I believe login sessions are stored in localStorage so users will not be able to stay logged in moving across subdomains.
What is the recommended way to create this sort of application or am I better keeping the entire application as I have it currently using /admin /learner. I am against this solution as it is causing the codebase to grow large (with lots of if hasRole 'admin' type code) very quickly and in order to keep the application as secure as possible I like the idea of having completely subscriptions and publications.
Setup a nginx proxy in front of meteor, that routes the subdomains to the same location. So it is actually the same application but to the user it doesnt look like it.
The http section of that config will look something like this:
http {
server {
listen 80;
server_name nvqhq.com;
location / {
proxy_pass http://localhost:3000/marketing;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name admin.nvqhq.com;
location / {
proxy_pass http://localhost:3000/admin;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name learners.nvqhq.com;
location / {
proxy_pass http://localhost:3000/learners;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}
}
gist
In this setup by default the login probably only works on the /marketing level. So you might have to change the domain the session cookies are set for in meteor.
But first try to get this setup running.
According to iron-router Issue 223 there is no option for subdomain routing so I won't be able to have a common routes file serving all three subdomains.
There is an easy way to deal with this part at least. You just need to create a local shared package that contains your common routes.
Remember and set the PACKAGE_DIRS variable to point to your shared package folder, then you can add your package to both apps in the usual meteor add myshared:package way.
Notes
Like you I break large apps down into smaller micro-apps. Whilst this is a good technique it instantly creates the problem of how to access shared components, such as routes, templates, design-assets, collections etc. To solve this I structure my apps according to the feature-package pattern - which I would thoroughly recommend.
This means my app consists entirely of smart packages, each implementing the app-specific functions relating to a single feature including, if required, a routes file. I also have a library of shared feature packages that implement the common, re-usable parts of each feature, again with their own routes file if required.
Gone are the days of monolithic routes files and Meteor.IsClient, Meteor.IsServer switches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With