I think I’ve got this figured out, I did a couple tests and they worked great. But I wanted to post the process here so others can maybe identify any gotchas I may have missed. Will gladly welcome any input from @arunoda.
Let’s say I have two small apps, app1 and app2, which I want to deploy as app1.com and app2.com. I have a single Ubuntu server running (currently just a virtual machine for testing).
In my first test (which failed), I installed nginx, Node, and MongoDB manually on the server. Locally, I ran mup init
, configured mup.json
, then ran mup deploy
. I got some errors, something about fiber and npm. So I restored a server snapshot to revert all the manual installs I had done (except nginx).
Attempt #2: I configured mup.json
to install Node and Mongo for me automatically. This worked great. The mup deploy
process worked and I was able to surf to app1.com (I modified my /etc/hosts file). Works great!
The nginx conf file looks like this:
server {
listen *:80;
server_name app1.com;
access_log /var/log/nginx/app.dev.access.log;
error_log /var/log/nginx/app.dev.error.log;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header X-Forwarded-For $remote_addr;
}
}
Not too sure what those headers are for, this is just a conf I grabbed from the official mup GitHub. It works though!
The second part of my test was to see if I could deploy app2 to the same server. For app2’s mup.json
, I set it so it did not set up Node, Mongo, or PhantomJS, since they were already installed via app1. I also set the environment variable PORT
to 3001
for app2 (app1 is on 3000). I deployed, and then made a new nginx conf file, app2.com.conf
:
server {
listen *:80;
server_name app2.com;
access_log /var/log/nginx/app.dev.access.log;
error_log /var/log/nginx/app.dev.error.log;
location / {
proxy_pass http://127.0.0.1:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header X-Forwarded-For $remote_addr;
}
}
And this all seems to work great! I haven’t tested whether Kadira will work with two apps on the same server (I assume it will). But so far so good. And when I update app1 or app2, I just run mup deploy
again and it pushes the new code to the server seamlessly.
Is this how it’s done? Am I doing anything wrong? Is there a better way?