Well, if you just ignore SSL for now (or want to figure out SSL for yourself later on), the below guide should work:
The basic idea
.. is to spawn multiple instances of the same application with different databases (mongo, the usual case) depending on the base URL.
We are going to use the following settings for the virtual hosts:
- Site #1 :
www.example1.com
- Meteor port:
3000
- MongoDB endpoint/url:
mongodb://localhost:27017/example1
- Site #2 :
www.example2.com
- Meteor port:
3001
- MongoDB endpoint/url:
mongodb://localhost:27017/example2
Preparing the meteor
instances
Install foreman
via rubygems
:
Create a foreman
Procfile
file in your meteor project directory. Using the data above (don't include the bullets :D):
web1: ROOT_URL=http://www.example1.com/ PORT=3000 MONGO_URL=mongodb://localhost:27017/example1 meteor
web2: ROOT_URL=http://www.example.com/ PORT=3001 MONGO_URL=mongodb://localhost:27017/example2 meteor
-OR- if you use the meteor bundle
version:
web1: ROOT_URL=http://www.example1.com/ PORT=3000 MONGO_URL=mongodb://localhost:27017/example1 node bundle/main.js
web2: ROOT_URL=http://www.example2.com/ PORT=3001 MONGO_URL=mongodb://localhost:27017/example2 node bundle/main.js
You can then run foreman start
directly on the same directory (add a &
at the end to send to background). or you could install it as a service / upstart script via foreman export
(this may vary for other linux distros, please refer to Foreman docs : http://ddollar.github.io/foreman/ ):
sudo foreman export --app meteors --user <meteor files owner> upstart /etc/init
Preparing nginx
From here on out, the configuration for nginx should now be pretty straightforward:
server {
listen 80;
server_name www.example1.com example1.com;
location / {
proxy_pass http://localhost:3000;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80;
server_name www.example2.com example2.com;
location / {
proxy_pass http://localhost:3001;
proxy_set_header X-Real-IP $remote_addr;
}
}
Let me know if this works for you, although you mentioned that you already used SilkJS instead, I'll just leave this here for anyone else that's interested on the solution.