Tag Archives: howto

HOWTO Cache S3 Objects with Varnish

Varnish is an amazing tool. In fact I refer to it as the Internet band-aid. If you are having problems with your web site, put some Varnish machines in front of it and voila, problem solved. In fact I feel it’s so crucial that at Phyber we install it by default on every Datacenter build we do.

Which brings me to the point of this post. I hate NFS. I hate it passionately. Mostly because I hate the way people use it. Conversations like, “I have 10 dual quad core app servers with 48 gig ram each and all of our images mounted on a P4 2.4 with 4GB ram and some IDE hard drives. Why is our site slow?” My solution – host your user uploaded content on an object store. It doesn’t matter which, just pick one. MogileFS, Amazon S3, SWIFT, etc… They all work great, no single point of failure, and no single hard drive as a choke point. As an added bonus, you can scale and scale and scale.

So what do you do if you want to control your S3 serving costs? Cache your objects with Varnish of course. I found this little tidbit here today and it’s worth saving/sharing for the future.

backend s3 {
.host = "s3.amazonaws.com";
.port = "80";
}

sub vcl_recv {
if (req.url ~ "\.(css|gif|ico|jpg|jpeg|js|png|swf|txt)$") {
unset req.http.cookie;
unset req.http.cache-control;
unset req.http.pragma;
unset req.http.expires;
unset req.http.etag;
unset req.http.X-Forwarded-For;

set req.backend = s3;
set req.http.host = "my_bucket.s3.amazonaws.com";

lookup;
}
}

sub vcl_fetch {
unset obj.http.X-Amz-Id-2;
unset obj.http.X-Amz-Meta-Group;
unset obj.http.X-Amz-Meta-Owner;
unset obj.http.X-Amz-Meta-Permissions;
unset obj.http.X-Amz-Request-Id;

set obj.ttl = 1w;
set obj.grace = 30s;
}

HOWTO Improve iPhone Battery Life

There are quite a few guides on how to improve the iPhone 4S / IOS 5 battery life. If you are just starting to research this search for:

  • Disabling APP Notifications
  • Disabling Location Services
  • Disabling System Services

I found a new one this week – disconnect your AT&T MicroCell. I don’t know what the cause of this one is, but my battery drain slowed to about 25% of the rate before with the MicroCell on. I was never really happy with the MicroCell, and it literally sucks. My reception and call quality is actually better now without it.

Name Based SSL Virtual Hosting

Wait, before you say to yourself that it’s impossible to use Name Based SSL Virtual Hosting and that you have to use IP Based SSL Virtual Hosting checkout this link:

http://wiki.apache.org/httpd/NameBasedSSLVHostsWithSNI

It turns out that there is an undocumented (or poorly documented) extension to the SSL protocol called Server Name Indication.

The solution is an extension to the SSL protocol called Server Name Indication (RFC 4366), which allows the client to include the requested hostname in the first message of its SSL handshake (connection setup). This allows the server to determine the correct named virtual host for the request and set the connection up accordingly from the start.

With SNI, you can have many virtual hosts sharing the same IP address and port, and each one can have its own unique certificate (and the rest of the configuration).

Of course there is a gotcha – your clients need to be running a modern browser (no IE6), but really who cares? This is just too awesome to pass up.

HOWTO Create ISO on Mac OS X

Found here:

1. Insert CD/DVD source

2. Fire up a Terminal, you can then determine the device that is you CD/DVD drive using the following command:


$ drutil status
Vendor Product Rev
MATSHITA DVD-R UJ-835E GAND

Type: DVD-ROM Name: /dev/disk1
Cur Write: 8x DVD Sessions: 1
Max Write: 8x DVD Tracks: 1
Overwritable: 00:00:00 blocks: 0 / 0.00MB / 0.00MiB
Space Free: 00:00:00 blocks: 0 / 0.00MB / 0.00MiB
Space Used: 364:08:27 blocks: 1638627 / 3.36GB / 3.13GiB
Writability:
Book Type: DVD-ROM

3. Unmount the disk with the following command:


$ diskutil unmountDisk /dev/disk1
Disk /dev/disk1 unmounted

4. Create the ISO file with the dd utility (may take some time):


$ dd if=/dev/disk1 of=file.iso bs=2048

5. Test the ISO image by mounting the new file (or open with Finder):


$ hdid file.iso

6. The ISO image can then be burnt to a blank CD/DVD.

Sharing a Screen Session

Let’s assume that I elubow want to share my console with jdoe. The easiest way to do this next part is to actually name your screen session. So let’s call our session test.

$ screen -S test

This will create the session and put you in it. Now we need to add the access control. Note: You can automate the multiuser piece by adding it to you .screenrc.

CTRL-A
:multiuser on

CTRL-A
:acladd jdoe

All jdoe has to do now is connect to the same machine and type the following command:

$ screen -x elubow/test   # $user/$session_name

There are other security combinations as the above gives jdoe full access. Here are a few common ones:

:aclchg user +rx  # Give ‘user’ read-only access
:aclchg user -x “#,at,aclchg,acladd,acldel,quit”  # Don’t allow ‘user’ any of the previous commands
:aclchg user +rwx  # Give ‘user’ read-write access (open permission on the session)

via Sharing a Screen Session | Erics Tech Blog.

Set the time zone on a per user basis

Continuing on my general rant that all computer systems should use UTC/GMT for their system clocks the question is often posed by users that want to see their own local time when they log into a remote computer.

Procedure – set the time zone on a per user basis

Open user ~/.bashrc or ~/.bash_profile file using vi text editor and set up TZ environment variable. Append or SET TZ as follows:

export TZ=”/usr/share/zoneinfo/{TIMEZONE-DIRECTORY}/{TIMEZONE_FILE}>”

If your username is foo and you would like to set TZ to Asia/Calcutta (INDIA IST) type command:

# vi /home/foo/.bashrc

Append following:

export TZ="/usr/share/zoneinfo/Asia/Calcutta"

Save and close the file.

(via http://www.cyberciti.biz/faq/howto-linux-set-time-zone-per-user-basis/)

HOWTO Install OS X on a Dell Mini 9

I just finished installing OS X on my Dell Mini 9 pic (as an aside – probably one of the best form factors I have owned for a traveling laptop). The instructions here:

How-To: Install Mac OS X – DellEFI Method

are pretty good. I followed Section 2 Part A. One thing to note, when booting the system via the “small” USB drive you will have to press “esc” and select the larger USB drive to boot from. The syslinux/isolinux on the small USB drive will continue to boot in a loop until you break the cycle. Other than that everything worked like a charm right from the start (camera, audio, wifi, etc…).

I still need to install and tweet some additional settings and my 16 GB USB drive will always be close by (6 GB installation). Additional links and information are below – enjoy.