Monday, 17 September 2012

Amazon EC2 Basics (Part 2)

The next step would be to associate an elastic IP with your EC2 instance and setup an Apache server:
  1. From your Amazon console, click elastic IPs and Allocate a new address.
  2. Associate it to your EC2 instance (if you don't associate with an instance, you'll be charged).
  3. Wherever you registered your domain name (Godaddy, Namecheap, etc), you're going to have to change the Address Record (A record) to point to your IP. e.g., for Namecheap, click "Manage domains", the "All host records", and enter your EC2 IP address for both the fields as shown below:


  4. You should be able to head over to your registered address (e.g., foo.com) on port 8080 now and see the tomcat manager.
  5. You might want to install Apache 2 (if you want, otherwise, you can just let Tomcat work as a web server instead of a servlet container; using Apache 2 as the server with Tomcat as the container would allow you to fiddle around with modules). In this example, we're going to be using mod_proxy to proxy requests to Tomcat. Apache listens on port 80 and Tomcat on port 8080.
  6. Installing and starting apache is simple:
    • ssh into your instance
    • type sudo yum -y install httpd
    • type sudo /sbin/chkconfig httpd on
    • type sudo /sbin/service httpd start
    • /var/www/html/ is the root web directory; httpd.conf is located at /etc/httpd/conf; mod_proxy is located at /etc/httpd/modules
    • note that after changing httpd.conf, you should restart apache using sudo /sbin/service httpd restart
  7. Before doing anything else, you need to modify your Amazon security group to open up port 80:
    • on your Amazon console, click Security Groups
    • check the box of your security group, click "Inbound", create a custom TCP rule for port 80 (port range would be 80) and add this rule
  8. Also, you might want to modify port 8080 to only accept requests from your instance for added security:
    • on your Amazon console, click Security Groups
    • check the box of your security group, click "Inbound", create a custom TCP rule for port 8080 (port range would be 8080) and under "Source", add your elastic IP e.g., some.ip.foo.bar/32
    • if you were following Part 1 of this series, you should remove the old rule for port 8080, where the "Source" was 0.0.0.0/0
  9. Next, modify your httpd.conf file for any context path that you wish to forward to Tomcat. In this example, I'm forwarding / to http://foo.com:8080/myapp. Note that by default, mod_proxy is already configured properly in this file (otherwise, follow this link, modifying as appropriate):
    • ProxyPass         /  http://foo.com:8080/myapp
      ProxyPassReverse  /  http://foo.com:8080/myapp
  10. Also modify the Tomcat server.xml file:
    • vim /etc/tomcat7/server.xml
    • Make sure that you comment out existing lines which deal with port 8080 and instead add the following line:
    • <Connector port="8080" proxyName="www.foo.com" proxyPort="80"/>
  11. Restart your Tomcat and Apache, and you should be all set. Just type foo.com and you should be able to view your website.

27 comments:

  1. Minecraft Premium HesapMinecrafthesabim.com sizlere çok daha uygun fiyatlı bir şekilde minecraft premium hesap satmak amacıyla kurulmuş bir şirkettir. Şirketimizde çalışan bütün kişiler konular hakkında yeterli bilgiye sahiptir ve Minecraft Premium hesabınızla ilgili bir sorun olduğu zaman 7/24 ulaşabilmeniz için hazır beklemektedirler.

    ReplyDelete
  2. hepsibahis Yüksek bahis oranları sunan en güncel canlı bahis şirketi olan hepsibahis firmasına buradan direk giriş yapın. Youwin adı ile tanınan ve Türkiye deki ismi hepsi bahis olarak kullanılan iddaa firması ile ilgili detaylı bilgileri öğrenin.

    ReplyDelete
  3. bahis siteleri Avrupa da yasal olarak faaliyet gösteren bir çok güvenilir bahis sitesi için güncel giriş adresleri Bahis5XL sitemizde. Bahis5XL.com ile bir çok yabancı bahis şirketi hakkında tanıtım yazılarını inceleyerek, size uygun en iyi iddaa sitesini seçebilirsiniz. Canlı bahis siteleri için en çok bedava deneme bonusu veren Kıbrıs ve Malta lisanslı Türkçe bahis sitelerini Bahis5XL ile inceleyin. Türkiye nin en güncel 2020 bahis siteleri listesi burada.

    ReplyDelete
  4. 1xbet türkiye 1xbet Türkiye, online bahis şirketi hakkında giriş ve inceleme bilgileri. Onebahis firması için 2020 güncel yeni giriş adresi, ödemeler ve üyelik işlemleri için detaylı bilgiler, 1xbahis sayfamızda yer almakta.

    ReplyDelete
  5. meal kits Making cooking a little easier. It's hard, it takes time and who's got the time after a long day of work, looking after kids and being on your feet all day ? I bet you don't and neither do I.. making cheap and tasty modern day meal kits the new normal among all the changes going on in our world today.

    ReplyDelete
  6. less than one dollar web hosting Domain hosting can be hit and miss when it comes to finding it cheap. Don’t get me wrong there are cheap web hosting options, but how about “super cheap and affordable” web hosting. Less than a dollar is “truly” affordable web hosting and this is a chance to get access to web hosting that is consistent and reliable when it comes to affordable web hosting.

    ReplyDelete
  7. BUY SPOTIFY PLAYS REAL PLAYS TO BOOST YOUR MUSIC.
    We will promote your tracks and give you very good promotion Buy spotify plays

    ReplyDelete
  8. investment strategy GET UNIQUE INVESTMENT IDEAS FROM AN EXPERIENCED FUND MANAGER TARGETING 5X - 10X+ RETURNS.

    ReplyDelete

  9. burner weight loss pills Authentic Option LLC offers collection of natural herbal products for skincare, hair care, and weight loss. We specialize in thermal weight loss, electrostimulation for muscle toning, cellulite removal, under-eye bags treatment and skincare products. We have an amazing range of beard growing products.

    ReplyDelete
  10. xanax bar mg This dosage provides relief of anxiety for up to 6 hours after it has been ingested, which can help you focus on what needs to be done without being disrupted.

    ReplyDelete
  11. Online Reputation Repair Reputation Repair Service removes criminal history information and deletes criminal records. Creates positive content that replaces negative search results.

    ReplyDelete
  12. Facts about addiction Addiction stands as the top public health problem in America outstanding all other major diseases including stroke, heart diseases and even cancer. The population of addicts is far larger than the patients suffering from the three mentioned diseases in America with sufferers ranging in millions.

    ReplyDelete
  13. Crunchyroll Crunchyroll is a dedicated anime streaming service that uploads over 30,000 episodes of top-rated anime episodes to subscribe members to it. Crunchyroll offers a comprehensive selection of high-quality dubbed anime series available for viewing no matter what time of day or night. All users can enjoy streaming live anime trailers, latest episodes, and popular anime show in the Crunchyroll catalog.

    ReplyDelete