[docs] style cleanup for cdn/dns/storage

This commit is contained in:
geemus 2011-04-11 17:58:50 -07:00
parent 25aa6b4343
commit b7232727d2
3 changed files with 51 additions and 51 deletions

View File

@ -1,6 +1,6 @@
---
layout: default
title: cdn
title: CDN
---
Faster websites are better. <a href="http://www.websiteoptimization.com/speed/tweak/design-factors/">Better experience</a>, <a href="http://exp-platform.com/Documents/IEEEComputer2007OnlineExperiments.pdf">better sales</a>, <a href="http://www.stevesouders.com/blog/2009/07/27/wikia-fast-pages-retain-users/">you name it</a>. Unfortunately, making a website faster can be tough. Thankfully a content distribution network, or CDN, can give you great performance bang for your buck. A CDN helps speed things up by putting copies of your files closer to your users. It's like the difference between pizza delivery from across the street and pizza delivery from the next town over.
@ -19,9 +19,9 @@ Now you'll need to <a href="https://aws-portal.amazon.com/gp/aws/developer/subsc
# create a connection to the service
cdn = Fog::CDN.new({
:provider =&gt; 'AWS',
:aws_access_key_id =&gt; AWS_ACCESS_KEY_ID,
:aws_secret_access_key =&gt; AWS_SECRET_ACCESS_KEY
:provider => 'AWS',
:aws_access_key_id => AWS_ACCESS_KEY_ID,
:aws_secret_access_key => AWS_SECRET_ACCESS_KEY
}
## Setting Up Your CDN
@ -29,9 +29,9 @@ Now you'll need to <a href="https://aws-portal.amazon.com/gp/aws/developer/subsc
Now you'll need to create a 'distribution' which represents a mapping from the CDN to your domain. For the examples we'll pretend we are working on 'http://www.example.com', but you can just switch it to your actual domain. Some <a href="http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateDistribution.html">other options</a> are available, but the only other one we need to fill in is OriginProtocolPolicy. This sets what to do about http vs https. We will use 'match-viewer' which returns the same protocol as the request, but you can also choose 'http-only' which always returns http responses.
data = cdn.post_distribution({
'CustomOrigin' =&gt; {
'DNSName' =&gt; 'www.example.com',
'OriginProtocolPolicy' =&gt; 'match-viewer'
'CustomOrigin' => {
'DNSName' => 'www.example.com',
'OriginProtocolPolicy' => 'match-viewer'
}
})
@ -60,12 +60,12 @@ But, just in case you need to update things I'll run through how you can make ch
distribution_id,
etag,
{
'CustomOrigin' =&gt; {
'DNSName' =&gt; 'www.example.com',
'OriginProtocolPolicy' =&gt; 'match-viewer'
'CustomOrigin' => {
'DNSName' => 'www.example.com',
'OriginProtocolPolicy' => 'match-viewer'
},
'CallerReference' =&gt; caller_reference,
'Enabled' =&gt; 'false'
'CallerReference' => caller_reference,
'Enabled' => 'false'
}
)

View File

@ -1,6 +1,6 @@
---
layout: default
title: dns
title: DNS
---
The power and flexibility of the cloud are amazing. But sometimes it can be a pain to chase your resources around and keep everything up to date. This is especially true of keeping track of addresses for DNS, but thankfully more and more API driven options are available, allowing you to automate your DNS to keep up with your hardware changes.
@ -18,9 +18,9 @@ For this first example we will use Zerigo (see below for how to use other provid
# create a connection to the service
dns = Fog::DNS.new({
:provider =&gt; 'Zerigo',
:zerigo_email =&gt; ZERIGO_EMAIL,
:zerigo_token =&gt; ZERIGO_TOKEN
:provider => 'Zerigo',
:zerigo_email => ZERIGO_EMAIL,
:zerigo_token => ZERIGO_TOKEN
}
## Getting in the Zone
@ -28,8 +28,8 @@ For this first example we will use Zerigo (see below for how to use other provid
The first thing you need to do to prepare for your DNS excursion is create a zone for your domain. The zone will contain all of the more specific records that you will create later. You will just need to specify the domain, which should be your url without the 'http' or 'www' parts, and an email address. Then you can create the zone with your DNS connection:<!--more-->
zone = @dns.zones.create(
:domain =&gt; 'example.com',
:email =&gt; 'admin@example.com'
:domain => 'example.com',
:email => 'admin@example.com'
)
Now that you have a zone you will need to update your registrar to let them know what DNS servers are responsible for your domain. You can ask the zone what values to use:
@ -41,25 +41,25 @@ Now that you have a zone you will need to update your registrar to let them know
With your new zone in hand you can add records as needed. First and foremost you will probably want the 'www' version of your site to point to whatever your ip might be:
record = @zone.records.create(
:ip =&gt; '1.2.3.4',
:name =&gt; 'example.com',
:type =&gt; 'A'
:ip => '1.2.3.4',
:name => 'example.com',
:type => 'A'
)
Adding other records is similarly easy, for instance if we want 'www.example.com' to go to the same place, we can use a cname record:
record = @zone.records.create(
:ip =&gt; 'example.com',
:name =&gt; 'www',
:type =&gt; 'CNAME'
:ip => 'example.com',
:name => 'www',
:type => 'CNAME'
)
Or, similarly you might want to have your blog elsewhere:
record = @zone.records.create(
:ip =&gt; '4.3.2.1',
:name =&gt; 'blog.example.com',
:type =&gt; 'A'
:ip => '4.3.2.1',
:name => 'blog.example.com',
:type => 'A'
)
You can add more specifics if you need to, but reasonable defaults make it just that easy. You can also add any other kind of DNS record you might need for mail or other purposes, you can find a nice overview of record options and types <a href="http://en.wikipedia.org/wiki/Domain_Name_System#DNS_resource_records">on Wikipedia</a>.
@ -69,9 +69,9 @@ You can add more specifics if you need to, but reasonable defaults make it just
If you already have an account with another service you can just as easily use this same code with different credentials. fog currently supports <a href="http://aws.amazon.com/route53/">AWS Route 53</a>, <a href="http://bluebox.net">Blue Box</a>, <a href="http://dnsimple.com">DNSimple</a>, <a href="http://www.linode.com">Linode</a>, <a href="http://www.slicehost.com">Slicehost</a> and <a href="http://www.zerigo.com/managed-dns">Zerigo</a>; so you can have your pick. As an example you can connect to AWS instead of Zerigo:
dns = Fog::DNS.new(
:provider =&gt; 'AWS',
:aws_access_key_id =&gt; AWS_ACCESS_KEY_ID,
:aws_secret_access_key =&gt; AWS_SECRET_ACCESS_KEY
:provider => 'AWS',
:aws_access_key_id => AWS_ACCESS_KEY_ID,
:aws_secret_access_key => AWS_SECRET_ACCESS_KEY
)
## Go Forth and Resolve

View File

@ -1,6 +1,6 @@
---
layout: default
title: storage
title: STORAGE
---
Having Ruby experience makes you hirable; but how can you stand out? You need to demonstrate your abilities. What better way than using Ruby and "the cloud" to store and serve your resume!
@ -34,15 +34,15 @@ First, create a connection with your new account:
# create a connection
connection = Fog::Storage.new(
:provider =&gt; 'AWS',
:aws_secret_access_key =&gt; YOUR_SECRET_ACCESS_KEY,
:aws_access_key_id =&gt; YOUR_SECRET_ACCESS_KEY_ID
:provider => 'AWS',
:aws_secret_access_key => YOUR_SECRET_ACCESS_KEY,
:aws_access_key_id => YOUR_SECRET_ACCESS_KEY_ID
)
# First, a place to contain the glorious details
directory = connection.directories.create(
:key =&gt; "fog-demo-#{Time.now.to_i}", # globally unique name
:public =&gt; true
:key => "fog-demo-#{Time.now.to_i}", # globally unique name
:public => true
)
# list directories
@ -50,9 +50,9 @@ First, create a connection with your new account:
# upload that resume
file = directory.files.create(
:key =&gt; 'resume.html',
:body =&gt; File.open("/path/to/my/resume.html"),
:public =&gt; true
:key => 'resume.html',
:body => File.open("/path/to/my/resume.html"),
:public => true
)
If you are anything like me, you will continually tweak your resume. Pushing updates is easy:
@ -73,9 +73,9 @@ directory = connection.directories.get("proclamations1234567890")
# also, create(attributes) is just new(attributes).save, so you can also do:
file = directory.files.new(
:key =&gt; 'resume.html',
:body =&gt; 'improvements',
:public =&gt; true
:key => 'resume.html',
:body => 'improvements',
:public => true
)
file.save
@ -92,9 +92,9 @@ More clouds? How much extra stuff will you have to do for these services!?! Hard
Sign up <a href="http://gs-signup-redirect.appspot.com/">here</a> and get your credentials <a href="https://sandbox.google.com/storage/m/">here</a>.
connection = Fog::Storage.new(
:provider =&gt; 'Google',
:google_storage_secret_access_key =&gt; YOUR_SECRET_ACCESS_KEY,
:google_storage_access_key_id =&gt; YOUR_SECRET_ACCESS_KEY_ID
:provider => 'Google',
:google_storage_secret_access_key => YOUR_SECRET_ACCESS_KEY,
:google_storage_access_key_id => YOUR_SECRET_ACCESS_KEY_ID
)
## Rackspace CloudFiles
@ -102,20 +102,20 @@ Sign up <a href="http://gs-signup-redirect.appspot.com/">here</a> and get your c
Rackspace has <a href="http://www.rackspacecloud.com/cloud_hosting_products/files">Cloud Files</a> and you can sign up <a href="https://www.rackspacecloud.com/signup">here</a> and get your credentials <a href="https://manage.rackspacecloud.com/APIAccess.do">here</a>.
connection = Fog::Storage.new(
:provider =&gt; 'Rackspace',
:rackspace_username =&gt; RACKSPACE_USERNAME,
:rackspace_api_key =&gt; RACKSPACE_API_KEY
:provider => 'Rackspace',
:rackspace_username => RACKSPACE_USERNAME,
:rackspace_api_key => RACKSPACE_API_KEY
)
Then create, save, destroy as per fog-for-AWS. The `:public =&gt; true` option when creating directories (see above) is important for Rackspace; your folder and files won't be shared to Rackspace's CDN and hence your users without it. Similarly the `:public =&gt; true` on files is important for AWS and Google or they will be private.
Then create, save, destroy as per fog-for-AWS. The `:public => true` option when creating directories (see above) is important for Rackspace; your folder and files won't be shared to Rackspace's CDN and hence your users without it. Similarly the `:public =&gt; true` on files is important for AWS and Google or they will be private.
## Local Storage
While you are working out the kinks you might not want to do everything live though, ditto for while you are running tests, so you have a couple options to try before you buy. First, you can use a local provider to store things in a directory on your machine.
connection = Fog::Storage.new(
:provider =&gt; 'Local',
:local_root =&gt; '~/fog'
:provider => 'Local',
:local_root => '~/fog'
)
## Mocking out Cloud Storage