Setting Sail with AWS and Lightsail

Lukie Kang
3 min readAug 10, 2017

--

I decided it was high time I got some hosting space for some front and back end web development I have been doing.

Nothing too fancy, nothing too hidden from me.

I have a GoDaddy account for my business but I was not enamoured with paying the prices they offered for a virtual node.js. So I decided to shop around. There is a lot of overkill out there, charging lots for services I probably didn’t need.

As I searched, I remember reading how Amazon is really cheap and handy so I signed up for AWS.

First thoughts: What the hell is that naming convention?

Eventually I found a site that did help make sense of it: https://www.expeditedssl.com/aws-in-plain-english

Eventually I bumbled into Lightsail which was alot more friendly! Plus $5 a month, I can swing that for something I will barely use but potentially need 24/7

It was easy enough to create an instance and I was jsut about smart enough to realise I needed a static IP to go with it lest it changes on me. All easy, but of course, I would find plenty of minefields to getting the web app running properly…

So here are the issues I had (because I am a newbie, not Lightsail’s fault…mostly…)

Q1. How do I Connect to SSH from my computer?

A. Putty will do it.

Q2. But it says I need a cert, I used Putty/PuttyGen to create that following guides I searched for

Q3. Cool, I am in the terminal… now how do I add my awesome web apps?

A. Filezilla will do the job, again needs to be configured for the SSH cert

Q4. Ok, how I have put my files on, and yay, the web app is running on my IP:Port…..But I cant get to it on my browser!

A. Relex, buddy. Firewall controls are kept in Lightsail’s settings, allow port 3000 or whatever and you are in business!

Q5. Well you say that, but yes, if I type in my IP and then port it loads. That’s awesome…. BUT…. I want it to use my domain.

A. Lightsail can sort that out if you go to DNS settings you can add the A record for the domain you have elsewhere. Apparently Amazon offer a Route 53 for domain registration, which of course, I didnt realise at the time….

Q5. OK, DNS is up, and www.<site>.co.uk doesnt work, it only works if I type in the port… argh!…How do I fix that? There seems to be a douzen answers to this on the web including some that seem overkill when all I want to do is make port 80 (http) go to port 3000.

A. Yup, I have no idea but I did find a command to do just that:

sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000

Q6. Sweet! Now my site loads running my node app on port 3000. Until I close my SSH! Then its gone, what gives?

A. Ok, that happens as the process is a child of the SSH session. If that goes, so does the kids.

There is a lot of discussion of the best way to do this:

https://stackoverflow.com/questions/12701259/how-to-make-a-node-js-application-run-permanently

You can figure out the pros and cons later, for now just use Screen. (Google it with node)

Q6. Excellent, everything is working. I wish I could say the same for my email which hasnt been working this last few hours…

A. Um, when Lightsail said to change the nameservers on the domain hoster, did you actually do that?

Me: Yup…. oh…

Smart me: OK, ignore that, just change the A record, revert those name servers back to normal, unless you want to host your email there too!

Me: Phew, all fixed, though it took a few terrifying minutes to happen!

Smart Me: Good job, now you have figured out how to get Lightsail up and running, you will actually have to write those web apps you want to host instead of that crappy placeholder.

Me: ….. crap.

--

--

Lukie Kang
Lukie Kang

Written by Lukie Kang

All about the things I bumble into as a Web Dev

No responses yet