24 Jul 2018
Installing free SSL on AWS EC2 machine( Meteor version 1.6) using LetsEncrypt

Installing free SSL on AWS EC2 machine( Meteor version 1.6) using LetsEncrypt

It’s delivery time in VAYUZ. Couple of project already on the production environment and some are in the last sprint. And every Developer will agree with me that the last sprint of any project is the longest sprint. Configuring an environment to a live server is a big task altogether. And if it’s on AWS, then it throws more challenges to the developers like Memory Management, SSL configuration etc.

Recently we deployed one of the variant of our social Networking engine “BITOVN” on AWS. Except one issue, we were done with all the tests and checks on the Production Environment. And the only issue which was left was the installation of SSL on the EC2 instance. Since this product is completely powered by JS ecosystem(Node in Backend, meteor in frontend), this became a different challenge all together.

SSL

Installation of meteor project on AWS itself could be a real headache if you are not familiar with AWS environment. But SSL certificate installation is one such process that usually causes severe pain for the Developers. And we also faced the same problem. Like every developer we Googled for this problem but most of the content which was available on the web for this issue is almost 2-3 years old. And many  things has changed since then. We somehow finally managed to add the SSL certificate after many hits and trails.

Post that we felt a need for an article which can help others who are doing the same task and facing the problem that we faced. So here is a solution to your problem. This blog will help you in setting up free SSL certificate on AWS EC2 instance. Let’s start.

Installation Steps

  1. Login with SSH command on your Ubuntu machine.
  2. Go to your project directory by typing  – cd  /var/www/html/
  3. Go inside your project folder, then in app-deploy folder and run the following command –   mup stop
    • This command will stop the current instance that is running on the AWS.
  4. Next step is to move out of the current folder by using the following command
    • cd .. 
    • And then move to the following location – var/www/html.
    • You can use the following command to move to HTML folder – cd  /var/www/html/
  5. Now lets install LetsEncrypt on your virtual machine.
    • Let’s Encrypt is a certificate authority that provides free X.509 certificates for Transport Layer Security (TLS) encryption via an automated process designed to eliminate the hitherto complex process of manual creation, validation, signing, installation, and renewal of certificates for secure websites.
    • type this command  to install LetsEncrypt- git clone https://github.com/letsencrypt/letsencrypt
  6. Now go inside LetsEncrypt folder with –    
    • cd letsencrypt
  7. Next step is to generate the required SSL certificate with the command
    • ./letsencrypt-auto certonly –standalone
  8. Once this command is executed, it will give you the path where your certificates were generated. So navigate to that folder with this command –
    • cd /etc/letsencrypt/live/YourSiteName.com
  9. Next step is changing the permission for the following folders –
    • chmod go+x /etc/letsencrypt/archive
    • chmod go+x /etc/letsencrypt/live
  10. Go back to your project & then inside app deploy and  restart your mup instance with command – mup start
  11. Post this command your machine is back in the game. Congrats you have installed SSL successfully on the server.
  12. Since SSL is up we want all the users to access the platform through HTTPS even though he has used HTTP at his end. And to do so we need to add forcessl package.  Following is the command to add forcessl package –
    • meteor add force-ssl
  13. In your mup.js file add this
    meteor: {
    name: ‘YourSiteName’,
    path: ‘../../YourSiteName’,
    servers: {
    one: {}
    },
    ssl: {
    crt: “/etc/letsencrypt/live/YourSiteName.com/fullchain.pem”,
    key:”/etc/letsencrypt/live/YourSiteName.com/privkey.pem”,
    port: 443
    },
    buildOptions: {
    serverOnly: true,
    },
    env: {
    ROOT_URL: ‘https://YourSiteName.com’,
    MONGO_URL: ‘mongodb://localhost/meteor’
    },
    dockerImage: ‘abernix/meteord:node-8.4.0-base’,
    deployCheckWaitTime: 60,
    enableUploadProgressBar: true,
    }
  14. Save these changes.
  15. Setup mup and redeploy it again with command
    • mup setup && mup deploy

Once this is Complete, SSL would be installed on our website. Enjoy free SSL for next 3 months. If you like this article, please like, share and comment. Have a great day.

About Philomathes Jigyasu

Philomathes (pronounced as fillo-MAY-thus) is a fictional character at VAYUZ (https://www.vayuz.com), who is on a never ending journey called “LEARNING”. In a way, Philomathes embodies VAYUZ - Way of life, which is if you are not learning then you are not breathing. The word Philomathes, comes from the Greek roots philo and philein meaning "to love" and the Greek roots mathos (MAH-thos) and mathesis (muh-THAYSIS) meaning “learning”. Philomathes through his Blogs and Vlogs (Video Blogs) will share his experience, learnings and thoughts. In his tryst to learn and understand, he would also seek answers to questions. So if you would like to join him in this incredible journey called “ life” then feel free to write to him on philomathes.jigyasu@vayuz.com. Always remember, knowledge is all around us, we just need to keep our guards down and senses on.

Leave a Comment