1
votes

I am going to finish my Meteor app in a few weeks. So the problem that I will face - how to make my app available to other people.

Firstly I bought a droplet on Digital Ocean. And started to read about the ways to deploy meteor app to production server.

I found 2 totally different ways to do that!

The first one is pretty simple (and so I really love it). Here is the link. I have to do a few steps - create a droplet with Ubuntu 14.04, then connect to this droplet via ssh, then install and run mup. After that anybody can access to my app. I worry, that there is no ssl support (my project is e-commerce, so I really need https-connection), but then I found in mup docs a short article How to set up SSL with Mup. So everything is perfect at first glance.

But then I found another way to deploy meteor app. Here is link. It is much more complicated. First I need to install node and mongo on my droplet. Then install and configure nginx. And then after many steps comes Meteor installation. Author don't explain why people need do deploy app this way, assuming that it is obviously to everyone. His explanation is "The problem with this is that it isn’t wise to run an application like Meteor through your public port (which is 80)".

I admit I have no experience and knowledge in such questions. The one thing that I can say exactly is that I need a really proper way to deploy e-commerce meteor app. And it doesn't matter I won't sleep many hours by doing this.

So question is: which one way is proper? And (it is important) why?

Either security and performance are important for this project. I am also going to use prerender.io or spiderable (for seo purposes) and fast render, if it can have an influence on your answers. and really thank you for answers guys!

1

1 Answers

4
votes

You can deploy your Meteor App on server via different mechanism . There are lots of way to do the same thing. Like as you said you also found two ways to do that. So in first link you used Meteor up for deployment your application as you successfully deployed . In second approach you need to first login to the server and than create user than install everything needed to your server machine after that you need to setup Nginx.

So as i guess your question is related to "Nginx" . And you want to know

1)Why we need to use Nginx

2)Which one is the better approach

So answer for your first question is as follows:-

Nginx (pronounced "engine x") is a web server that is used for many purpose mainly use for proxy pass. Means using nginx you can redirect your request from one url to another and the actual url is hidden from the UI (For securety purpose and for redirection). Like in meteor your app is by default running on 3000 so one way is that you can open 3000 port and run your application on that port. But via nginx you can run your app on 80 port and as user hit any event than in nginx you can configure address where you want to send your request. Like you can send them to 3000 port. So now user don't know in actual where is your request going on because you show them port 80 but in actual your request is go to 3000 port. So this is the one advantage of using nginx same there are lots more.

So for configuration of nginx you just need to install nginx if you are using ubuntu than via simple command-:

sudo apt-get install nginx

then setting in nginx configuration file that is under the following directory:-

/etc/nginx/sites-enabled/default

just open this file and setup up your configuration here like:-

server {

listen       80;
        server_name  localhost;

        root   /home/parveen/meteor/app;
        location / {
                index /index.html;

        }

        location /api {
           proxy_pass http://localhost:3000;
        }
}

In this way you can configure your nginx setting as you want please read nginx documentation for detail.

After that you need to start your server using forever or nohup which you want to use so that your server will not stop as you exit from the login of server.

Conclusion:-

In the second approach you need to install everything by yourself via ssh login to your server than configuration of nginx and and then run your server. If you do any changes than again you need to update your changes to server and then stop meteor app then restart that. But this is more secure approach and you can do what you want to do.

In first approach they are using mup (Meteor up) that do so many of works for you . You just need to do some configuration you can use Docker or as define in the blog (droplet) link you shared and just need to run meteor up command and that will first create a bundle for your app than run that so in the first approach if you do any changes than you not need to login again to your server update changes , what you need to do is just run again the same command and that will create new bundle with updates and run your project. But i don't think that is more secure.

So its depend on your requirement and choice which you want to use.

If you have any question than most welcome.

Hope this would help!

Thanks