Hi I have successfully deployed my app to amazon aws using this railscast
http://railscasts.com/episodes/347-rubber-and-amazon-ec2
my app shows up here on this url http://web01.foo.com/
on my local machine only.
I am slightly confused, if I deployed it why can't other people see it. How do you make it live for all to see?
if anyone is familiar with this rails cast please enlighten me, I am still trying to learn about the architectures of amazon aws hosting.
Thank You
Judy
Rubber automatically sets up your /etc/hosts file for you. In order to make it publicly viewable you need to have the DNS servers point to that address in your /etc/hosts file.
So basically, go to your DNS host provider, and add an entry that points the domain name you own to the ip address of web01.foo.com and it should load okay.
In your amazon EC2 dashboard click on the instance. You will get the public domian of your server. Use PUBLIC domain not private one
Related
I am trying to make an ios application that uses Amazon Web Services as its backend. I have an MySQL database in RDS and want to query this database from the app to retrieve content for the app. After some research, it looks like I should approach this by adding my own API for querying the database to an EC2 instance. Then, rather than directly accessing the RDS instance from the app, I access the API on the EC2 instance which accesses the RDS instance for me. Firstly, is this the way to go? I'm open to other suggestions too.
Here's what I have done so far, after reading this post:
Installed apache and php on my EC2 instance.
Obtained an elastic IP address for my EC2 instance.
Added a file (let's call it retrieve-data.php) to apache that uses my RDS instance endpoint, username, and password to query the database and return data.
From my ios application, I can then send an http request to elastic_ip_address_of_my_ec2_instance/retrieve-data.php to get the data from my RDS database in my app. Is this the way to go? Can this be improved upon in any way?
Edit: changing this answer to whats in my comment below;
The solution is what is suggested in How to connect amazon RDS in iOS, which is installing a webserver on the EC2 instance and writing a web app to make your RDS calls for you. This will involve some kind of web programming, there's a simple explanation here in the top comment. Then you can use RestKit to implement the calls from your app to the EC2 instance: github.com/RestKit/RestKit
For anyone who might find this useful, below is a summary of the steps you can take to get this all set up.
Set-up:
There are three options covered in the below steps:
A = NO domain name, NO load balancing
B = YES domain name, NO load balancing
C = YES domain name, YES load balancing
(A+B+C) Create an EC2 instance.
(A+B+C) Install all the necessities on your instance. At the very least, you'll want apache2 and whatever language(s) you wish to use for any backend scripts you want to run on your instance. I've used php.
(A+B) If you don't want to get a domain name to use to access your EC2 instance, or if you want a domain name but don't need load balancing, you'll want to get an elastic IP address for your instance. This can be easily done through AWS. (C) If you want to use a domain name and load balancing, you won't need an elastic IP address. Go ahead and get yourself a domain name. I used namecheap.com. They currently (August, 2015) have .xyz TLDs for just $1.18 USD/year.
(A+B+C) Add your backend files to the apache web server you installed on your EC2 instance in step 2.
(B+C) Set up a hosted zone in Amazon Route 53. NOTE: Route 53 is NOT included in the AWS free tier and is therefore NOT FREE. The costs are here. (B only) Add A record(s) to your Route 53 hosted zone that point to the elastic IP of your EC2 instance.
(B+C) Transfer the name servers of your domain name to the 3-5 name servers Route 53 gave you after completing step 5. The transfer will be done from the site you registered your domain name with.
(C) Set up load balancing for your EC2 instance(s) in AWS. Note your load balancer's end point.
(C) Add alias record(s) to your Route 53 hosted zone that point to your load balancer's end point.
Accessing your files on EC2
Let's say you have a php script myscript.php that you saved to your server in step 4. To run this script on your EC2 server after finishing the set up, you can do the following:
A - Open up a web browser and enter the following into the address bar: elastic_IP_of_your_EC2_instance/myscript.php
B+C - Open up a web browser and enter the following into the address bar: yourdomain.com/myscript.php
Hope this is helpful!
I've been coding on iOS for awhile. I'm getting started to use AWS as a cloud backend to store my user's data for my iOS app as well as a server that can handle real time event in multiplayer mode. I understand that there are many services like Amazon Cognito that allows user login via public providers, Dynamo DB that provides noSQL storage, EC2 that help me create server instances. However, I'm really confuse on how I can actually get started.
Here's some stuff that I really need help on:
I don't really want to use public providers like facebook for my users to sign in/sign up. I'd really prefer it if there could be relational database that is similar to how I cache data on local sqlite files using core data.
And I also need some help on getting my ID tokens for those services if I choose not to use cognito, or must I?
I would really appreciate it if you guys can give me some clues on how I can get started on these. Thank you so much! :D
Depending on how you expect your app to evolve there are several approaches you can take.
Option 1: Minimal scalability / low cost
All you really need is a single free EC2 micro instance. On the instance you can build a full LAMP stack in seconds. Once you have built it you can start writing an application to handle your app in your preferred language. Ruby is a la mode but any language will work. Your database will be stored on the actual instance. If you go with this route, one thing you should do is use an elastic IP address so that if your server ever goes down you can point the elastic IP to another instance. You should also periodically backup your server.
Option 2: Maximum scalability / variable cost
Use RDS to store your database. This will mean that any EC2 instance will be able to reach your data so you can have an unlimited number of servers. Then build an EC2 instance just like in option 1 but point your application to the RDS instance. Use a load balancer in front of your EC2 instance to scale up in response to changes in utilisation. And the elastic IP address should point to the load balancer.
Building a LAMP stack on EC2
Open the EC2 console
Select launch instance
Pick the Linux AMI offered by Amazon and a micro instance
Create a .pem key (keep is safe on your system or you will not be able to access your instance)
Select the default security group
Open your terminal window and type: ssh -i path_to_pem ec2-user#your_instance_public_address
In the EC2 instance type sudo yum update
Then type sudo yum install httpd24 php55 php55-mysqlnd mysql55
sudo apachectl start
You now can navigate to the public address of your instance in safari and assuming I did not forget any steps you should see the apache welcome page.
So I host with company X and have my domain on there. I deployed my app to heroku and pointed my domain at it. I can't wrap my head around if I am hosting my site on heroku now or if I am hosting it on company X's servers.
I would assume I'm hosting on herokus server because that is the most logical, but just keep having this brainfart.
Could someone please explain this to me?
Your application is on Heroku's server. All company X has done is perform the DNS magic necessary to map the friendly URL (www.yoursite.com) to your Heroku deployment.
Amazon
You should also be aware that Heroku doesn't actually "store" the app on its own servers - it uses Amazon's ec2 cloud to create instances of your app
So although you have your domain with company X, your app handled through heroku, it will actually be running in one of Amazon's data centers
Keep that in mind when you start to grow (you may find benefits of using Amazon directly)
I want to know if someone's site is using Heroku, Engine Yard, self-hosted on EC2, or something different. They use Ruby on Rails. Is there a good way to figure this out?
Your only clue will be looking at where the DNS record is pointing at, eg nslookup www.kyan.com will show you that it's a CNAME to a herokuapp.com domain. Heroku and EY all use EC2 so the IP address range will show you it's an Amazon IP address. Perhaps if you reveal the domain we can all have a poke.
I need to connect to an API with my Heroku/Rails app where I need to have a static IP.
I know about the add-on proximo - https://devcenter.heroku.com/articles/proximo - but it is insanely priced, so that's out of the question.
Most people in my situation ends up deploying to EC2 instead and using a an Elastic IP as their static IP. I've also tried this and it works, but I find the whole flow of playing around with EC2 really cumbersome.
I've read in some answers that it is possible to set up an EC2 server and use it as a proxy for your Heroku/Rails app - Heroku Static IP for SFTP - but it sounds very cryptic for a person who is not very server-savvy.
Can someone give a step-to-step tutorial on how to set up your Heroku/Rails app to use your EC2 instance as a proxy?
In short: I would just switch to AWS. There is a little bit of a learning curve but it's not too difficult. Here is a presentation I gave on it geared toward front-end devs:
https://speakerdeck.com/krunkosaurus/intro-to-scaling-your-web-app-on-the-cloud-with-aws-for-frontend-developers-part-1
Amazon has 9 regions each with 3-5 "Availability Zones". I know that Heroku uses AWS but am not sure if you get to decide (or know) which AWS region and AZ your actual server is hosted.
Whatever it is, you should host your proxy server in the same Region (better yet, even the same Availability Zone). Setting up an EC2 there is easy just use the web console and be sure to give it an Elastic IP so the adress doesn't ever change. Then point your DNS away from your Heroku instance (dyno?) to this EC2 instance. From there you can either install Nginx or HAProxy.
I've just setup QuotaGuard Static as a more robust, better value static IP service that can be used by Heroku apps.
It's hosted on EC2 so you get the low latency benefits without having to start managing servers.
Hello you can use this answer to see how to use NGINX as a reverse proxy.
https://stackoverflow.com/a/27874505/1345865
http://blog.talenox.com/post/107675614745/how-to-setup-static-ip-on-heroku
Fixie is very affordable option for getting static IP address on Heroku. The documentation section has a lot of examples for different languages and frameworks, including Ruby.