<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Failverse</title>
	<atom:link href="http://failverse.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://failverse.com</link>
	<description>Welcome to the Failverse.</description>
	<lastBuildDate>Fri, 27 Apr 2012 00:50:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Using Temporary URLs on Rackspace Cloud Files</title>
		<link>http://failverse.com/using-temporary-urls-on-rackspace-cloud-files/</link>
		<comments>http://failverse.com/using-temporary-urls-on-rackspace-cloud-files/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 19:41:43 +0000</pubDate>
		<dc:creator>Ryuujinx</dc:creator>
				<category><![CDATA[Rackspace Cloud]]></category>

		<guid isPermaLink="false">http://failverse.com/?p=428</guid>
		<description><![CDATA[The ability to have temporary URLs is something that has been requested for quite some time. Since Cloud Files runs on openstack swift, we get some of the new features available, such as temporary URLs. This will allow you to create temporary URLs so your end users can consume your product, while having it expire [...]]]></description>
			<content:encoded><![CDATA[<p>The ability to have temporary URLs is something that has been requested for quite some time. Since Cloud Files runs on openstack swift, we get some of the new features available, such as temporary URLs. This will allow you to create temporary URLs so your end users can consume your product, while having it expire after a few days, or minutes, so it isn&#8217;t possible to share the link, limiting unauthorized downloads. </p>
<p>Keep in mind, this isn&#8217;t officially supported by Rackspace yet, so you&#8217;re on your own for it, however it does work and you can start taking advantage of it now. Read on after the jump for the how-to. </p>
<p><span id="more-428"></span></p>
<p>The first thing we need(Aside of an account), is the API key. You can locate this in your control panel under &#8216;Your Account&#8217;, if you&#8217;re using Cloud Files, you more then likely already have this. Once you have your API key, we need to create authenticate and create/set our key. </p>
<p>Let&#8217;s go ahead and authenticate first:</p>
<pre>$ curl -I -X GET -H X-Auth-User:USER -H X-Auth-Key:APIKEY https://auth.api.rackspacecloud.com/v1.0
HTTP/1.1 204 No Content
Server: Apache/2.2.3 (Red Hat)
vary: X-Auth-Token,X-Auth-Key,X-Storage-User,X-Storage-Pass
X-Storage-Url: https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48
Cache-Control: s-maxage=5028
Content-Type: text/xml
Date: Mon, 16 Apr 2012 18:41:46 GMT
X-Auth-Token: ~
X-Storage-Token: ~
X-Server-Management-Url: https://servers.api.rackspacecloud.com/v1.0/473948
Connection: Keep-Alive
X-CDN-Management-Url: https://cdn.clouddrive.com/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48
Content-Length: 0
</pre>
<p>Next, let&#8217;s go ahead and make a key. It can be whatever you want (Alphanumeric) within the limitations of the header length, however I recommend just echoing out some text and making an md5 or sha of it. </p>
<pre>$ echo -n "Random text so I can make my key with it and such" | md5sum
7acc0fe42358c0232053b3fc7254609c  -
</pre>
<p>Once we have this, we can go ahead and set it on our account:</p>
<pre>$ curl -i -X POST -H X-Auth-Token:~token -H X-Account-Meta-Temp-URL-Key:7acc0fe42358c0232053b3fc7254609c https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48
HTTP/1.1 204 No Content
Content-Length: 0
Content-Type: text/html; charset=UTF-8
X-Trans-Id: txd69ae1123b4d4f8c82ab1a38bfb3a499
Date: Mon, 16 Apr 2012 19:02:22 GMT
</pre>
<p>A few notes about your key, if you change it, it will invalidate every URL you have generated after about a minute (Due to caching), additionally, you can check it by issuing a HEAD against your account, so you won&#8217;t have to invalidate all your old URLS if you forget it -</p>
<pre>$ curl -I -H X-Auth-Token:TOKEN https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48
HTTP/1.1 204 No Content
X-Account-Object-Count: 52
X-Account-Meta-Temp-Url-Key: 7acc0fe42358c0232053b3fc7254609c
X-Account-Bytes-Used: 61839518344
X-Account-Container-Count: 2
Accept-Ranges: bytes
Content-Length: 0
X-Trans-Id: txa90bbf3e259443d5bd4c312adddc1767
Date: Mon, 16 Apr 2012 19:31:12 GMT
</pre>
<p>After you&#8217;ve set up your key on your account, we can go ahead and generate the URL using a python script:</p>
<pre>
import hmac
from hashlib import sha1
from time import time
method = 'GET'
expires = int(time() + TIME FROM NOW TO EXPIRE, IN SECONDS)
base = 'BASEURL'
path = 'PATH TO OBJECT'
key = 'THE KEY YOU CREATED'
hmac_body = '%s\n%s\n%s' % (method, expires, path)
sig = hmac.new(key, hmac_body, sha1).hexdigest()
print '%s%s?temp_url_sig=%s&#038;temp_url_expires=%s' % (base, path, sig, expires)
</pre>
<p>For comparison, here is what mine looked like:</p>
<pre>
import hmac
from hashlib import sha1
from time import time
method = 'GET'
expires = int(time() + 600)
base = 'https://storage101.dfw1.clouddrive.com'
path = '/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48/test/test.txt'
key = '7acc0fe42358c0232053b3fc7254609c'
hmac_body = '%s\n%s\n%s' % (method, expires, path)
sig = hmac.new(key, hmac_body, sha1).hexdigest()
print '%s%s?temp_url_sig=%s&#038;temp_url_expires=%s' % (base, path, sig, expires)
</pre>
<p>Now that we have the script made, we can generate our URL and give it to end users:</p>
<pre>$ python script.py

https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48/test/test.txt?temp_url_sig=d36692ce16ff22c80769dfce0712ff6fc9e4dd6c&#038;temp_url_expires=1334603603

$ curl -I "https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48/test/test.txt?temp_url_sig=d36692ce16ff22c80769dfce0712ff6fc9e4dd6c&#038;temp_url_expires=1334603603"
HTTP/1.1 200 OK
Last-Modified: Fri, 18 Nov 2011 23:32:41 GMT
Accept-Ranges: bytes
Etag: 8d777f385d3dfec8815d20f7496026dc
Content-Type: text/plain
Content-Length: 4
X-Trans-Id: txf8297b7c83d44a85bcb9d28c7141ca08
Date: Mon, 16 Apr 2012 19:03:41 GMT
</pre>
<p>Again, this exists in the Swift implementation for Rackspace Cloud, however it is not officially supported yet. If you have issues, you&#8217;re pretty much on your own. However it seems to work fine, and it will probably be in the documentation soon and officially supported, so you can start utilizing it now!</p>
]]></content:encoded>
			<wfw:commentRss>http://failverse.com/using-temporary-urls-on-rackspace-cloud-files/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating the Kittynet</title>
		<link>http://failverse.com/creating-the-kittynet/</link>
		<comments>http://failverse.com/creating-the-kittynet/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 20:44:21 +0000</pubDate>
		<dc:creator>Ryuujinx</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://failverse.com/?p=404</guid>
		<description><![CDATA[Have you ever wanted to just set up a wireless network that replaces pictures with cats? No? What&#8217;s wrong with you. In this article we&#8217;re going to talk about making the Kittynet. So you can leave it unsecured and have your neighbors be annoyed by pictures of cats everywhere, like so - (note: don&#8217;t go [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to just set up a wireless network that replaces pictures with cats?</p>
<p>No? What&#8217;s wrong with you. In this article we&#8217;re going to talk about making the Kittynet. So you can leave it unsecured and have your neighbors be annoyed by pictures of cats everywhere, like so -</p>
<p><img src="http://i.imgur.com/OHtOK.jpg" alt="The Kittynet is Live!" /><br />
(note: don&#8217;t go to that site.)</p>
<p>Read more after the jump.</p>
<p><span id="more-404"></span></p>
<p>For this setup, we will need the following:</p>
<ul>
<li>1 PC running Linux, with 3 Network Interface Cards</li>
<li>A spare wireless router, preferably flashed with DD-WRT or similar</li>
<li>The rest of your networking gear to serve your normal network.</li>
</ul>
<p>First, we need to set up the router to just route. I have three interfaces in mine &#8211; eth1, eth2 and eth3. eth1 will be my internal network, eth2 will be the public network, and eth3 will be for the WAP.</p>
<p>Let&#8217;s configure our interfaces. On Debian-based systems this is as simple as editing /etc/network/interfaces -</p>
<pre>auto lo
iface lo inet loopback
        post-up iptables-restore &lt; /etc/iptables.up.rules
auto eth2
iface eth2 inet dhcp
auto eth1
iface eth1 inet static
        address 10.1.1.1
        netmask 255.255.255.0
auto eth3
iface eth3 inet static
        address 10.1.2.1
        netmask 255.255.255.0</pre>
<p>Notice how eth1 and eth3 are on different subnets &#8211; this is important, make sure whatever internal addresses you use that they use different subnets.</p>
<p>Now, we need to tell the kernel that it&#8217;s allowed to forward traffic -</p>
<pre>sysctl -w net.ipv4.ip_forward=1 &gt;&gt; /etc/sysctl.conf</pre>
<p>Now that this is done, we need to set up some IPtables rules -</p>
<pre>iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE</pre>
<p>This is your external interface, this will tell it to nat everything properly. Unless you want to set the default policy to DROP, then you will be done. If you do want to set it to drop, you need to allow your internal networks. </p>
<pre>-A PREROUTING -i eth3 -j ACCEPT
-A PREROUTING -i eth1 -j ACCEPT
-A PREROUTING -i lo -j ACCEPT
-A PREROUTING -i eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT</pre>
<p>Now that it&#8217;s configured to route traffic through it, we need to set up a DHCP server on the router, I will be using dhcp3-server, you are welcome to use whatever you want &#8211; but this guide walks you through the configuration of this server.</p>
<p>In /etc/dhcp3/dhcpd.conf, you will need to set up your subnets -</p>
<pre>update-static-leases on;
ignore client-updates;
option domain-name "failverse.local.";
default-lease-time 600;
max-lease-time 7200;

subnet 10.1.1.0 netmask 255.255.255.0 {
        interface eth1;
        option domain-name-servers 8.8.8.8, 8.8.4.4;
        option broadcast-address 10.1.1.255;
        option subnet-mask 255.255.255.0;
        option routers 10.1.1.1;
        range 10.1.1.100 10.1.1.254;
        # People who live here.
        group {
                # Dewey Main
                host illu {
                        hardware ethernet 00:24:1d:1f:ae:36;
                        fixed-address 10.1.1.220;
                        }
                # Dewey Media
                host ryuujin {
                        hardware ethernet 00:1b:11:c3:28:45;
                        fixed-address 10.1.1.221;
                        }
                # PS3
                host Maemi {
                        hardware ethernet a8:e3:ee:5f:1c:04;
                        fixed-address 10.1.1.222;
                        }
                # Xbox
                host Shana {
                        hardware ethernet 7c:ed:8d:25:7f:8b;
                        fixed-address 10.1.1.223;
                        }
                }
        # Sharaa
        host sharaa {
                hardware ethernet 1c:6f:65:a7:ca:cb;
                fixed-address 10.1.1.20;
                }
        # Sharaa Media
        host sharaa-media {
                hardware ethernet 00:16:3E:44:C8:18;
                fixed-address 10.1.1.21;
                }
        # Sharaa Windows
        host sharaa-windows {
                hardware ethernet 00:46:6E:A4:C8:58;
                fixed-address 10.1.1.23;
                }
        }

# KITTIES
subnet 10.1.2.0 netmask 255.255.255.0 {
        interface eth3;
        option domain-name-servers 8.8.8.8, 8.8.4.4;
        option broadcast-address 10.1.2.255;
        option routers 10.1.2.1;
        range 10.1.2.100 10.1.2.200;
}</pre>
<p>I have included my entire config, in the event you want to set up machines that are statically assigned. The important parts are the options present in the KITTIES section. Go ahead and set up both subnets now, since we&#8217;d just come back and edit this file later anyway.</p>
<p>Now that your server is serving dhcp leases, make sure you set everything to come up on boot. Next we set up the proxy, install squid and apache2 from your friendly repository and edit /etc/squid3/squid.conf.</p>
<p>We need to set up three lines, two of them are just commented out -</p>
<pre>acl localnet src 10.1.2.0/24
http_access allow localnet
url_rewrite_program /var/www/scripts/images.pl</pre>
<p>Now, create /var/www/scripts and /var/www/content and place &#8216;images.pl&#8217; into scripts (source <a href="http://g0tmi1k.blogspot.com/2011/04/video-playing-with-traffic-squid.html">here</a>.) We&#8217;re going to modify the original script to use our own web server -</p>
<pre>#!/usr/bin/perl
########################################################################
# replaceImages.pl              --- Squid Script (Replace every image) #
# g0tmi1k 2011-03-25                                                   #
########################################################################
use IO::Handle;
use POSIX strftime;

$debug = 0;                      # Debug mode - create log file
$imageURL = "http://10.1.2.1/kitty.jpg";

$|=1;
$pid = $$;

if ($debug == 1) { open (DEBUG, '&gt;&gt;/tmp/replaceImages_debug.log'); }
autoflush DEBUG 1;

print DEBUG "########################################################################\n";
print DEBUG strftime ("%d%b%Y-%H:%M:%S\n",localtime(time()));
print DEBUG "########################################################################\n";
while (&lt;&gt;) {
   chomp $_;
   if ($debug == 1) { print DEBUG "Input: $_\n"; }
   if ($_ =~ m/.*$imageURL/) {
      print "$imageURL\n";
   }
   elsif ($_ =~ /(.*\.(gif|png|bmp|tiff|ico|jpg|jpeg|swf))/i) {   # Image format(s)
      print "$imageURL\n";
      if ($debug == 1) { print DEBUG "Image Replaced: $_ \n"; }
   }
   else {
      print "$_\n";
      if ($debug == 1) { print DEBUG "Output: $_\n"; }
   }
}

close (DEBUG);</pre>
<p>Download a picture of a cat you like into /var/www/content/kitty.jpg, and then we need to modify our DocumentRoot (and DirectoryIndex), Debian by default uses virtual hosts, so in /etc/apache2/sites-available/default -</p>
<pre>
&lt;VirtualHost *:80&gt;
   ServerAdmin webmaster@localhost
   DirectoryIndex kitty.jpg
   DocumentRoot /var/www/content
   &lt;Directory /&gt;
       Options FollowSymLinks
       AllowOverride None
   &lt;/Directory&gt;
   &lt;Directory /var/www/content&gt;
       Options Indexes FollowSymLinks MultiViews
       AllowOverride None
       Order allow,deny
       allow from all
   &lt;/Directory&gt;

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    &lt;Directory "/usr/lib/cgi-bin"&gt;
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    &lt;/Directory&gt;

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    &lt;Directory "/usr/share/doc/"&gt;
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
        &lt;/Directory&gt;

&lt;/VirtualHost&gt;
</pre>
<p>Now, we need to redirect their traffic from port 80, to our squid proxy -</p>
<pre>iptables -t nat -A PREROUTING -i eth3 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128</pre>
<p>In DDWRT on the WAP you&#8217;ll need to configure it to be a DHCP forwarded, pointing at 10.1.2.1, set its static ip to something like 10.1.2.6, and set it to just be a router and have no NAT, etc. This should be fairly straight forward to do, if you need help just glance through the DDWRT wiki.</p>
<p>Now that we have the WAP configured, we want to lock it down some.</p>
<pre>iptables -A INPUT -s 10.1.2.0/24 -d 10.1.1.1/32 -m comment --comment "Prevent Access to 10.1.1.1 from 10.1.2.0/24" -j REJECT --reject-with icmp-host-prohibited
iptables -A FORWARD -s 10.1.2.6/32 -d 10.1.1.0/24 -m comment --comment "Allow Access from the WAP for administration purposes" -m mac --mac-source 68:7F:74:26:3E:CB -j ACCEPT
iptables -A FORWARD -i eth3 -o eth1 -m comment --comment "Lockin down the networks" -j REJECT --reject-with icmp-host-prohibited
iptables -A FORWARD -p tcp --dport 53 -j ACCEPT
iptables -A FORWARD -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -p icmp -j ACCEPT
iptables -A FORWARD -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -s 10.1.2.0/24 -j REJECT --reject-with icmp-host-prohibited</pre>
<p>The initial three rules prohibit anything to access the 10.1.1.1 IP from 10.1.2.0/24(It&#8217;s not considered &#8220;forwarded&#8221; because it never leaves the box), to allow access to the WAP so you can manage it(You&#8217;ll obviously need to replace the mac with the mac of your specific WAP, I accomplished this by doing a ping from the router to the WAP, and then used tcpdump -e -i eth3 icmp to get it.), and not to allow any access to your other subnet.</p>
<p>Then we have some ACCEPT statements for port 80(HTTP), 53(DNS) and ICMP (You could technically lock this down further and only allow ping, but just ICMP should be fine). The final rule is a reject so that they are not able to access any port externally &#8211; this should prohibit abusing your network for things like bit torrent in most cases, however there is still the threat of them just downloading tons of things via HTTP.</p>
<p>Unfortunately, there isn&#8217;t really a quick and easy button to do this &#8211; you can experiment with tc, or try utilizing transmission limits on your DD-WRT device. This is something you&#8217;ll just need to play around with!</p>
<p>Make sure all your settings are saved, and then go ahead and unsecure your wireless to let your neighbors experience the Kittynet.</p>
]]></content:encoded>
			<wfw:commentRss>http://failverse.com/creating-the-kittynet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up an Nginx Reverse Proxy</title>
		<link>http://failverse.com/setting-up-an-nginx-reverse-proxy/</link>
		<comments>http://failverse.com/setting-up-an-nginx-reverse-proxy/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 01:03:15 +0000</pubDate>
		<dc:creator>Ryuujinx</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://failverse.com/?p=379</guid>
		<description><![CDATA[You might have noticed by now that I really like Nginx. I&#8217;ve had an article for using it as a load balancer with SSL termination already, and eventually I&#8217;ll get around to setting it up as a web server as well. For this article, I&#8217;ll set a situation. You have some PHP application on apache, [...]]]></description>
			<content:encoded><![CDATA[<p>You might have noticed by now that I really like <a href="http://nginx.org/">Nginx</a>. I&#8217;ve had an article for using it as a load balancer with SSL termination already, and eventually I&#8217;ll get around to setting it up as a web server as well. For this article, I&#8217;ll set a situation. You have some PHP application on apache, and have your mod_rewrite wizardry the way you want it, and everything is working -ok-. You&#8217;ve heard of this new Nginx thing and want to give it a shot, but don&#8217;t want to mess with testing everything on Nginx. So what you can do, is have Nginx listen and serve all your static content (Which it&#8217;s really good at), and pass your dynamic content(and whatever else) back to Apache to process. This article will go over the configuration of an Nginx reverse proxy, and modifying apache to work with it. </p>
<p><span id="more-379"></span></p>
<p>The first thing you need to do is install it. On Debian, this is quite simply -</p>
<p>Add the following to /etc/apt/sources.list</p>
<pre>deb http://nginx.org/packages/debian/ squeeze nginx
deb-src http://nginx.org/packages/debian/ squeeze nginx
</pre>
<p>Now install it:</p>
<pre># aptitude update
# aptitude install nginx</pre>
<p>Here&#8217;s some copy/pasta if you just want the configs:</p>
<p><strong>/etc/nginx/nginx.conf</strong></p>
<pre>user  nginx;
worker_processes  6;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    keepalive_timeout  10;

    #Compression Settings
    gzip on;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_min_length  1100;
    gzip_buffers 16 8k;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    # Some version of IE 6 don't handle compression well on some mime-types,
    # so just disable for them
    gzip_disable "MSIE [1-6].(?!.*SV1)";
    # Set a vary header so downstream proxies don't send cached gzipped
    # content to IE6
    gzip_vary on;

    include /etc/nginx/conf.d/*.conf;

}</pre>
<p>The first bit is pretty self explanatory. We set the user, the number of processes nginx will spawn, where it&#8217;s going to store the pid file, and the number of connections each worker will get. Moving down, we have an include(mime.types sets a lot of the MIME types), and set the default MIME type. Moving further down, we set the log format and allow sendfile (which bypasses using read() and write(), you can read about it some <a href="https://www.kernel.org/doc/man-pages/online/pages/man2/sendfile.2.html">here</a> and <a href="http://www.techrepublic.com/article/use-sendfile-to-optimize-data-transfer/1044112">here</a>.) We set a keepalive_timeout fairly low (it could probably stand be shorter, but 10 seconds should be fine). </p>
<p>The compression settings should be fairly obvious, if you want to read on the specifics on a parameter you can read about them <a href="http://wiki.nginx.org/HttpGzipModule">here</a>.</p>
<p>Next, we need to set up the actual proxying:</p>
<p><strong>/etc/nginx/conf.d/proxy.conf</strong></p>
<pre>server {

	listen 80;

	access_log off;
	error_log off;

	location / {
		proxy_pass	http://127.0.0.1:8080;
		proxy_redirect	off;	

		#Proxy Settings
		proxy_redirect     off;
		proxy_set_header   Host             $host;
		proxy_set_header   X-Real-IP        $remote_addr;
		proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
		proxy_max_temp_file_size 0;
		proxy_connect_timeout      90;
		proxy_send_timeout         90;
		proxy_read_timeout         90;
		proxy_buffer_size          4k;
		proxy_buffers              4 32k;
		proxy_busy_buffers_size    64k;
		proxy_temp_file_write_size 64k;
	}

	location ~* \.(?:ico|css|js|gif|jpe?g|png|bmp|html) {
		root /var/www;
		expires max;
		add_header Pragma public;
		add_header Cache-Control "public, must-revalidate, proxy-revalidate";
	}
}
</pre>
<p>In this section, we do a few things. First we define a server. A server in the context of nginx can be loosely defined as a virtualhost. For instance, if you wanted to have domain1.com and domain2.com, you would end up with two server blocks. In this case, we&#8217;re going to specify a server with no server name. If you are going to host multiple domains, you will need to make a .conf for each and set <em>server_name</em> as well as <em>root</em> for each domain unless you don&#8217;t want nginx to serve static content for some reason.</p>
<p>The next thing we do is specify two locations. The first specifies anything that matches /, and anything that matches something ending in .ico/css/etc. Nginx matches the most specific location. In this instance, that means /somedir/image.png will match the second rule, as matching &#8220;.png&#8221; is more specific then matching / (which will match every request to the server). In the ~* \. match, we serve the content with nginx directly &#8211; this is because nginx is very good at serving static content and there is no reason to proxy the requests to apache. We add a couple headers (for instance, telling the browser to cache the content as long as possible) and let it go on its way. The other location proxies the request to apache, setting some headers (such as X-Real-IP and X-Forwarded-For), and set the timeouts to the backend (90 seconds) and the buffer sizes. I will refer you (again) to the excellent documentation if you would like to know what all parameters are available, located <a href="http://wiki.nginx.org/HttpProxyModule">here</a>.</p>
<p>Finally, we need to change apache to listen on port 8080 instead of 80. The apache configurations vary significantly between distributions, so I won&#8217;t point to the specific files, but a grep -Ri should get you what you need.</p>
<p>The configurations we are concerned about are VirtualHost, NameVirtualHost and Listen.</p>
<p>You will need to modify them so they look like this:</p>
<pre>
NameVirtualHost *:8080
Listen 8080
<VirtualHost *:8080>
</pre>
<p>Once you have done this, check your configurations:</p>
<pre># service nginx configtest
# service apache configtest</pre>
<p>(note that it is httpd on redhat based systems), assuming everything checks out, restart apache, start nginx and set it to start on boot -</p>
<pre># service apache2 restart
# service nginx start
# update-rc.d nginx enable
</pre>
<p>Assuming everything went well, Nginx should now be solving all static content and relaying everything else back to apache. Enjoy your performance boost!</p>
]]></content:encoded>
			<wfw:commentRss>http://failverse.com/setting-up-an-nginx-reverse-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Net-install a custom linux distro on Cloud Servers</title>
		<link>http://failverse.com/net-install-a-custom-linux-distro-on-cloud-servers/</link>
		<comments>http://failverse.com/net-install-a-custom-linux-distro-on-cloud-servers/#comments</comments>
		<pubDate>Sun, 02 Oct 2011 02:24:22 +0000</pubDate>
		<dc:creator>Deuce</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Rackspace Cloud]]></category>

		<guid isPermaLink="false">http://failverse.com/?p=360</guid>
		<description><![CDATA[This guide will walk you through installing a custom linux distro to Rackspace Cloud Servers without the need of taring up a file system from a donor box. This particular guide is specific to openSuse, but the same method can be used to install other distros that support automated/remote install. This process is entirely unsupported [...]]]></description>
			<content:encoded><![CDATA[<p>This guide will walk you through installing a custom linux distro to Rackspace Cloud Servers without the need of taring up a file system from a donor box. This particular guide is specific to openSuse, but the same method can be used to install other distros that support automated/remote install.</p>
<p><strong>This process is entirely unsupported by Rackspace</strong>.</p>
<p>First, some documentation before we get started:<br />
<a href="http://en.opensuse.org/SDB:Remote_installation" target="_blank">http://en.opensuse.org/SDB:Remote_installation<br />
</a><a href="http://en.opensuse.org/SDB:Linuxrc" target="_blank">http://en.opensuse.org/SDB:Linuxrc</a></p>
<p><span id="more-360"></span></p>
<p>Spin up a box on the cloud. I went with Debian for this step, but you can use whichever variant of linux you please. First thing to do is to gather up your networking info: IPs, netmasks, gateway, static routes, and DNS servers (on Debian, just cat /etc/network/interfaces and /etc/resolv.conf for all of the info you need). Make a /boot and /boot/grub, and move to /boot. Now we need to grab the xen-compatible installer kernel and initrd:</p>
<pre>/boot# wget http://download.opensuse.org/distribution/11.4/repo/oss/boot/x86_64/vmlinuz-xen
/boot# wget http://download.opensuse.org/distribution/11.4/repo/oss/boot/x86_64/initrd-xen</pre>
<p>Now edit /boot/grub/menu.lst and make an entry for openSuse. We&#8217;re going to want it to look like this (fill in the network config with what you pulled previously):</p>
<pre>timeout 5
default 0
title openSuse Install
      root (hd0)
      kernel /boot/vmlinuz-xen textmode=1 noapic ssh=1 sshpassword="yoursshpassword" addswap=/dev/xvda2 install=http://download.opensuse.org/distribution/11.4/repo/oss/ hostip=serverip netmask=servernetmask gateway=servergateway nameserver=serverdnsserver
      initrd /boot/initrd-xen</pre>
<p>Submit a ticket to Rackspace support to enable PV-GRUB for you. Go ahead, I&#8217;ll wait.</p>
<p>If all goes well, you should see the box pinging after they switch it over to PV-GRUB (if all did not go well, kick the box into rescue mode and double check your work). SSH into it using user root and the password that you set in the &#8220;sshpassword&#8221; kernel option. Once you&#8217;re at the shell, run &#8220;yast&#8221;. This will launch the text based installer.</p>
<p>On the Installation Mode screen, un-select &#8220;Use Automatic Configuration&#8221;. On the Desktop Selection screen, select &#8220;Other&#8221; -&gt; &#8220;Minimal Server Selection (Text Mode)&#8221;. On the &#8220;Suggested Partitioning&#8221; screen, select &#8220;Edit Partition Setup&#8230;&#8221;. On the next screen tab to /dev/xvda1 and press enter. Then tab to &#8220;Edit&#8221; and hit enter. Match these settings <strong>(NOTE: Only use EXT3! PV-GRUB freaked out when I tried EXT4)</strong>:</p>
<pre>  Edit Partition /dev/xvda1
                        ┌Formatting Options───────────┐
                        │ (x) Format partition        │
                        │     File System             │
                        │     Ext3                    │
                        │     [     Options...      ] │
                        │ ( ) Do not format partition │
                        │     File system ID:         │
                        │     0x83 Linux              │
                        │ [ ] Encrypt device          │
                        └─────────────────────────────┘
                        ┌Mounting Options─────────────┐
                        │ (x) Mount partition         │
                        │     Mount Point             │
                        │     /                       │
                        │     [  Fstab Options...   ] │
                        │ ( ) Do not mount partition  │
                        └─────────────────────────────┘</pre>
<p>Then hit &#8220;Finish&#8221;, then &#8220;Accept&#8221;. Continue on with creating your user, uncheck &#8220;Automatic Login&#8221; (not sure how that would work for a server&#8230;.). I also unchecked &#8220;Use this password for system administrator&#8221; since I wanted to set a password for root. <strong>On the Installation Settings screen, be sure to enable SSH and open it in the firewall.</strong> Now hit Install. It should chug along just fine until it gets to installing grub. Don&#8217;t bother to retry installing the boot loader, just continue along. Stop it from rebooting and open up a second SSH connection to the box and run the following commands:</p>
<pre>~# mount /dev/xvda1 /mnt/
~# sed -i 's/hd0,0/hd0/' /mnt/boot/grub/menu.lst
~# umount /mnt/</pre>
<p>Now it is safe to reboot. Try to SSH to the box when it starts responding to ping. Congrats, you&#8217;ve just installed openSuse on Cloud Servers the less ghetto way =P.</p>
]]></content:encoded>
			<wfw:commentRss>http://failverse.com/net-install-a-custom-linux-distro-on-cloud-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Non-standard Size Bootable Floppy Image for PXE Boot</title>
		<link>http://failverse.com/creating-a-non-standard-size-bootable-floppy-image-for-pxe-boot/</link>
		<comments>http://failverse.com/creating-a-non-standard-size-bootable-floppy-image-for-pxe-boot/#comments</comments>
		<pubDate>Sun, 07 Aug 2011 01:32:18 +0000</pubDate>
		<dc:creator>Deuce</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Pxe]]></category>

		<guid isPermaLink="false">http://failverse.com/?p=311</guid>
		<description><![CDATA[The majority of motherboard manufactures still only allow you to update your BIOS either from within Windows, from a USB stick within the BIOS itself, or from a floppy with DOS. The first option doesn&#8217;t work with a linux box for obvious reasons. While the second option is nice for updating one box, it quickly [...]]]></description>
			<content:encoded><![CDATA[<p>The majority of motherboard manufactures still only allow you to update your BIOS either from within Windows, from a USB stick within the BIOS itself, or from a floppy with DOS. The first option doesn&#8217;t work with a linux box for obvious reasons. While the second option is nice for updating one box, it quickly becomes a hassle when you have an entire rack you need to update. And the third option is antiquated by any meaning of the word&#8230; or is it? While the days of floppies are long gone, the reign of the floppy image is still going strong in the world of PXE boot.</p>
<p>The biggest limitation of a floppy image is easily its size. 1.44MB is almost useless in today&#8217;s world of terabyte hard drives. Since BIOS images take up about 1MB, that leaves room for not much else. Meaning no scripting, no fancy menus, just the flasher program and your BIOS image. One of the most common methods around this limitation is to offsite your BIOS images to a samba share and instead use the 1.44MBs of space for network utilities. While this does work fine, it brings back bad memories of networking in DOS that I&#8217;d rather not experience again. Instead, I&#8217;ll walk you through how to expand a floppy image to whatever size is comfy for you, and most importantly, keep it bootable.<br />
<span id="more-311"></span><br />
<strong>Things you will need:</strong></p>
<ul>
<li style="font-weight: bold;"><span class="Apple-style-span" style="font-weight: normal;">A bootable floppy image (<a href="http://www.bootdisk.com/">http://www.bootdisk.com/</a> has a bunch)<br />
</span></li>
<li style="font-weight: bold;"><span class="Apple-style-span" style="font-weight: normal;">dd</span></li>
<li style="font-weight: bold;"><span class="Apple-style-span" style="font-weight: normal;">mkfs.msdos</span></li>
<li style="font-weight: bold;"><span class="Apple-style-span" style="font-weight: normal;">hexdump, for verification purposes<br />
</span></li>
<li style="font-weight: bold;"><span class="Apple-style-span" style="font-weight: normal;">A PXELINUX PXE boot environment<br />
</span></li>
</ul>
<p><strong>1. Procure a bootable floppy image</strong></p>
<p>Download your bootable floppy image and save it to a directory of your choosing. If your downloaded it from <a href="http://www.bootdisk.com/">http://www.bootdisk.com/</a>, chances are it&#8217;s saved as a Windows executable. Have no fear, just run unzip on it and it should extract the tasty image within:</p>
<pre>david@bt:~$ wget http://www.dq.com.pl/pliki/boot%20disk/boot98c.exe
 --2011-08-06 16:52:31--  http://www.dq.com.pl/pliki/boot%20disk/boot98c.exe
 Resolving www.dq.com.pl... 85.128.137.63
 Connecting to www.dq.com.pl|85.128.137.63|:80... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 864362 (844K) [application/x-msdownload]
 Saving to: `boot98c.exe'
100%[======================================&gt;] 864,362      529K/s   in 1.6s
2011-08-06 16:52:33 (529 KB/s) - `boot98c.exe' saved [864362/864362]
david@bt:~$ unzip boot98c.exe
 Archive:  boot98c.exe
 warning [boot98c.exe]:  105508 extra bytes at beginning or within zipfile
 (attempting to process anyway)
 file #1:  bad zipfile offset (local header sig):  211016
 (attempting to re-compensate)
 inflating: boot98c.IMA
 david@bt:~$ ls
 boot98c.exe  boot98c.IMA</pre>
<p><strong>2. Create a new floppy image with the size you want</strong></p>
<p>Now that we have our donor bootable floppy image with its delicious boot code, we need to create an empty floppy image with the new size. First, figure out how much space you need. For this tutorial I&#8217;m going with 10MB. Convert that value to KB (you can do this from within bash by running &#8220;expr $((<em>sizeinMB</em> &lt;&lt; 10))&#8221;), in my case that&#8217;s 10240. This is going to be the last argument we use in mkfs.msdos:</p>
<pre>david@bt:~$ expr $((10 &lt;&lt; 10))
10240
david@bt:~$ mkfs.msdos -I -v -C test.img 10240
mkfs.msdos 3.0.3 (18 May 2009)
test.img has 64 heads and 32 sectors per track,
logical sector size is 512,
using 0xf8 media descriptor, with 20480 sectors;
file system has 2 16-bit FATs and 4 sectors per cluster.
FAT size is 20 sectors, and provides 5101 clusters.
Root directory contains 512 slots.
Volume ID is df50ef01, no volume label.
david@bt:~$ du -h test.img
52K     test.img</pre>
<p>You may notice that the file size is only 52K. This is normal. This command just created the filesystem&#8217;s metadata. You can still mount it and the OS will see it as 10MB of space. Take note of the sector size (512 in this example), amount of heads (64), and sectors per track (32). You will need these later to calculate the amount of cylinders.</p>
<p><strong>3. Copy over boot information to new image</strong></p>
<p>Let&#8217;s compare the boot sector from the bootable image to the one we just created:</p>
<pre>david@bt:~$ hexdump -C -n 512 boot98c.IMA
00000000  eb 3c 90 2a 34 68 55 3c  49 48 43 00 02 01 01 00  |.&lt;.*4hU&lt;IHC.....|
00000010  02 e0 00 40 0b f0 09 00  12 00 02 00 00 00 00 00  |...@............|
00000020  40 0b 00 00 00 00 29 49  2d e1 18 42 4f 4f 54 39  |@.....)I-..BOOT9|
00000030  38 41 20 20 20 20 46 41  54 31 32 20 20 20 33 c9  |8A    FAT12   3.|
00000040  8e d1 bc fc 7b 16 07 bd  78 00 c5 76 00 1e 56 16  |....{...x..v..V.|
00000050  55 bf 22 05 89 7e 00 89  4e 02 b1 0b fc f3 a4 06  |U."..~..N.......|
00000060  1f bd 00 7c c6 45 fe 0f  38 4e 24 7d 20 8b c1 99  |...|.E..8N$} ...|
00000070  e8 7e 01 83 eb 3a 66 a1  1c 7c 66 3b 07 8a 57 fc  |.~...:f..|f;..W.|
00000080  75 06 80 ca 02 88 56 02  80 c3 10 73 ed 33 c9 fe  |u.....V....s.3..|
00000090  06 d8 7d 8a 46 10 98 f7  66 16 03 46 1c 13 56 1e  |..}.F...f..F..V.|
000000a0  03 46 0e 13 d1 8b 76 11  60 89 46 fc 89 56 fe b8  |.F....v.`.F..V..|
000000b0  20 00 f7 e6 8b 5e 0b 03  c3 48 f7 f3 01 46 fc 11  | ....^...H...F..|
000000c0  4e fe 61 bf 00 07 e8 28  01 72 3e 38 2d 74 17 60  |N.a....(.r&gt;8-t.`|
000000d0  b1 0b be d8 7d f3 a6 61  74 3d 4e 74 09 83 c7 20  |....}..at=Nt... |
000000e0  3b fb 72 e7 eb dd fe 0e  d8 7d 7b a7 be 7f 7d ac  |;.r......}{...}.|
000000f0  98 03 f0 ac 98 40 74 0c  48 74 13 b4 0e bb 07 00  |.....@t.Ht......|
00000100  cd 10 eb ef be 82 7d eb  e6 be 80 7d eb e1 cd 16  |......}....}....|
00000110  5e 1f 66 8f 04 cd 19 be  81 7d 8b 7d 1a 8d 45 fe  |^.f......}.}..E.|
00000120  8a 4e 0d f7 e1 03 46 fc  13 56 fe b1 04 e8 c2 00  |.N....F..V......|
00000130  72 d7 ea 00 02 70 00 52  50 06 53 6a 01 6a 10 91  |r....p.RP.Sj.j..|
00000140  8b 46 18 a2 26 05 96 92  33 d2 f7 f6 91 f7 f6 42  |.F..&amp;...3......B|
00000150  87 ca f7 76 1a 8a f2 8a  e8 c0 cc 02 0a cc b8 01  |...v............|
00000160  02 80 7e 02 0e 75 04 b4  42 8b f4 8a 56 24 cd 13  |..~..u..B...V$..|
00000170  61 61 72 0a 40 75 01 42  03 5e 0b 49 75 77 c3 03  |aar.@u.B.^.Iuw..|
00000180  18 01 27 0d 0a 49 6e 76  61 6c 69 64 20 73 79 73  |..'..Invalid sys|
00000190  74 65 6d 20 64 69 73 6b  ff 0d 0a 44 69 73 6b 20  |tem disk...Disk |
000001a0  49 2f 4f 20 65 72 72 6f  72 ff 0d 0a 52 65 70 6c  |I/O error...Repl|
000001b0  61 63 65 20 74 68 65 20  64 69 73 6b 2c 20 61 6e  |ace the disk, an|
000001c0  64 20 74 68 65 6e 20 70  72 65 73 73 20 61 6e 79  |d then press any|
000001d0  20 6b 65 79 0d 0a 00 00  49 4f 20 20 20 20 20 20  | key....IO      |
000001e0  53 59 53 4d 53 44 4f 53  20 20 20 53 59 53 7f 01  |SYSMSDOS   SYS..|
000001f0  00 41 bb 00 07 60 66 6a  00 e9 3b ff 00 00 55 aa  |.A...`fj..;...U.|
00000200
david@bt:~$ hexdump -C -n 512 test.img
00000000  eb 3c 90 6d 6b 64 6f 73  66 73 00 00 02 04 01 00  |.&lt;.mkdosfs......|
00000010  02 00 02 00 50 f8 14 00  20 00 40 00 00 00 00 00  |....P... .@.....|
00000020  00 00 00 00 00 00 29 01  ef 50 df 20 20 20 20 20  |......)..P.     |
00000030  20 20 20 20 20 20 46 41  54 31 36 20 20 20 0e 1f  |      FAT16   ..|
00000040  be 5b 7c ac 22 c0 74 0b  56 b4 0e bb 07 00 cd 10  |.[|.".t.V.......|
00000050  5e eb f0 32 e4 cd 16 cd  19 eb fe 54 68 69 73 20  |^..2.......This |
00000060  69 73 20 6e 6f 74 20 61  20 62 6f 6f 74 61 62 6c  |is not a bootabl|
00000070  65 20 64 69 73 6b 2e 20  20 50 6c 65 61 73 65 20  |e disk.  Please |
00000080  69 6e 73 65 72 74 20 61  20 62 6f 6f 74 61 62 6c  |insert a bootabl|
00000090  65 20 66 6c 6f 70 70 79  20 61 6e 64 0d 0a 70 72  |e floppy and..pr|
000000a0  65 73 73 20 61 6e 79 20  6b 65 79 20 74 6f 20 74  |ess any key to t|
000000b0  72 79 20 61 67 61 69 6e  20 2e 2e 2e 20 0d 0a 00  |ry again ... ...|
000000c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200</pre>
<p>For those who are interested, you can see what each offset means at <a href="http://en.wikipedia.org/wiki/File_Allocation_Table#Boot_Sector" target="_blank">Wikipedia</a>.</p>
<p>As you can see, the disk we made is missing a bunch of information (the asterisk means bunches of zeros). We want to copy over all of the boot instructions, but we don&#8217;t want to overwrite the geometry information so we can retain our 10MB image. The jump instructions and the OEM data are located in the first 11 bytes (offset 00 to 0A in hexadecimal). We want to copy that from the bootable image to the new one. From offset 0B to offset 3E we have the geometry information, which we want to retain on the new image. From offset 3E to offset 200, we have the actual OS boot code. We obviously want to copy that over to the new image. To make all of these changes we bust out dd:</p>
<pre>david@bt:~$ dd if=boot98c.IMA of=test.img bs=1 count=11 conv=notrunc
11+0 records in
11+0 records out
11 bytes (11 B) copied, 0.000163496 s, 67.3 kB/s
david@bt:~$ dd if=boot98c.IMA of=test.img bs=1 skip=62 seek=62 conv=notrunc count=450
450+0 records in
450+0 records out
450 bytes (450 B) copied, 0.0491807 s, 9.1 kB/s</pre>
<p>The reason we only counted to 450 is because 512-62=450. Now let&#8217;s compare the two boot sectors:</p>
<pre>david@bt:~$ hexdump -C -n 512 boot98c.IMA                                      
00000000  eb 3c 90 2a 34 68 55 3c  49 48 43 00 02 01 01 00  |.&lt;.*4hU&lt;IHC.....|
00000010  02 e0 00 40 0b f0 09 00  12 00 02 00 00 00 00 00  |...@............|
00000020  40 0b 00 00 00 00 29 49  2d e1 18 42 4f 4f 54 39  |@.....)I-..BOOT9|
00000030  38 41 20 20 20 20 46 41  54 31 32 20 20 20 33 c9  |8A    FAT12   3.|
00000040  8e d1 bc fc 7b 16 07 bd  78 00 c5 76 00 1e 56 16  |....{...x..v..V.|
00000050  55 bf 22 05 89 7e 00 89  4e 02 b1 0b fc f3 a4 06  |U."..~..N.......|
00000060  1f bd 00 7c c6 45 fe 0f  38 4e 24 7d 20 8b c1 99  |...|.E..8N$} ...|
00000070  e8 7e 01 83 eb 3a 66 a1  1c 7c 66 3b 07 8a 57 fc  |.~...:f..|f;..W.|
00000080  75 06 80 ca 02 88 56 02  80 c3 10 73 ed 33 c9 fe  |u.....V....s.3..|
00000090  06 d8 7d 8a 46 10 98 f7  66 16 03 46 1c 13 56 1e  |..}.F...f..F..V.|
000000a0  03 46 0e 13 d1 8b 76 11  60 89 46 fc 89 56 fe b8  |.F....v.`.F..V..|
000000b0  20 00 f7 e6 8b 5e 0b 03  c3 48 f7 f3 01 46 fc 11  | ....^...H...F..|
000000c0  4e fe 61 bf 00 07 e8 28  01 72 3e 38 2d 74 17 60  |N.a....(.r&gt;8-t.`|
000000d0  b1 0b be d8 7d f3 a6 61  74 3d 4e 74 09 83 c7 20  |....}..at=Nt... |
000000e0  3b fb 72 e7 eb dd fe 0e  d8 7d 7b a7 be 7f 7d ac  |;.r......}{...}.|
000000f0  98 03 f0 ac 98 40 74 0c  48 74 13 b4 0e bb 07 00  |.....@t.Ht......|
00000100  cd 10 eb ef be 82 7d eb  e6 be 80 7d eb e1 cd 16  |......}....}....|
00000110  5e 1f 66 8f 04 cd 19 be  81 7d 8b 7d 1a 8d 45 fe  |^.f......}.}..E.|
00000120  8a 4e 0d f7 e1 03 46 fc  13 56 fe b1 04 e8 c2 00  |.N....F..V......|
00000130  72 d7 ea 00 02 70 00 52  50 06 53 6a 01 6a 10 91  |r....p.RP.Sj.j..|
00000140  8b 46 18 a2 26 05 96 92  33 d2 f7 f6 91 f7 f6 42  |.F..&amp;...3......B|
00000150  87 ca f7 76 1a 8a f2 8a  e8 c0 cc 02 0a cc b8 01  |...v............|
00000160  02 80 7e 02 0e 75 04 b4  42 8b f4 8a 56 24 cd 13  |..~..u..B...V$..|
00000170  61 61 72 0a 40 75 01 42  03 5e 0b 49 75 77 c3 03  |aar.@u.B.^.Iuw..|
00000180  18 01 27 0d 0a 49 6e 76  61 6c 69 64 20 73 79 73  |..'..Invalid sys|
00000190  74 65 6d 20 64 69 73 6b  ff 0d 0a 44 69 73 6b 20  |tem disk...Disk |
000001a0  49 2f 4f 20 65 72 72 6f  72 ff 0d 0a 52 65 70 6c  |I/O error...Repl|
000001b0  61 63 65 20 74 68 65 20  64 69 73 6b 2c 20 61 6e  |ace the disk, an|
000001c0  64 20 74 68 65 6e 20 70  72 65 73 73 20 61 6e 79  |d then press any|
000001d0  20 6b 65 79 0d 0a 00 00  49 4f 20 20 20 20 20 20  | key....IO      |
000001e0  53 59 53 4d 53 44 4f 53  20 20 20 53 59 53 7f 01  |SYSMSDOS   SYS..|
000001f0  00 41 bb 00 07 60 66 6a  00 e9 3b ff 00 00 55 aa  |.A...`fj..;...U.|
00000200
david@bt:~$ hexdump -C -n 512 test.img                                         
00000000  eb 3c 90 2a 34 68 55 3c  49 48 43 00 02 04 01 00  |.&lt;.*4hU&lt;IHC.....|
00000010  02 00 02 00 50 f8 14 00  20 00 40 00 00 00 00 00  |....P... .@.....|
00000020  00 00 00 00 00 00 29 01  ef 50 df 20 20 20 20 20  |......)..P.     |
00000030  20 20 20 20 20 20 46 41  54 31 36 20 20 20 33 c9  |      FAT16   3.|
00000040  8e d1 bc fc 7b 16 07 bd  78 00 c5 76 00 1e 56 16  |....{...x..v..V.|
00000050  55 bf 22 05 89 7e 00 89  4e 02 b1 0b fc f3 a4 06  |U."..~..N.......|
00000060  1f bd 00 7c c6 45 fe 0f  38 4e 24 7d 20 8b c1 99  |...|.E..8N$} ...|
00000070  e8 7e 01 83 eb 3a 66 a1  1c 7c 66 3b 07 8a 57 fc  |.~...:f..|f;..W.|
00000080  75 06 80 ca 02 88 56 02  80 c3 10 73 ed 33 c9 fe  |u.....V....s.3..|
00000090  06 d8 7d 8a 46 10 98 f7  66 16 03 46 1c 13 56 1e  |..}.F...f..F..V.|
000000a0  03 46 0e 13 d1 8b 76 11  60 89 46 fc 89 56 fe b8  |.F....v.`.F..V..|
000000b0  20 00 f7 e6 8b 5e 0b 03  c3 48 f7 f3 01 46 fc 11  | ....^...H...F..|
000000c0  4e fe 61 bf 00 07 e8 28  01 72 3e 38 2d 74 17 60  |N.a....(.r&gt;8-t.`|
000000d0  b1 0b be d8 7d f3 a6 61  74 3d 4e 74 09 83 c7 20  |....}..at=Nt... |
000000e0  3b fb 72 e7 eb dd fe 0e  d8 7d 7b a7 be 7f 7d ac  |;.r......}{...}.|
000000f0  98 03 f0 ac 98 40 74 0c  48 74 13 b4 0e bb 07 00  |.....@t.Ht......|
00000100  cd 10 eb ef be 82 7d eb  e6 be 80 7d eb e1 cd 16  |......}....}....|
00000110  5e 1f 66 8f 04 cd 19 be  81 7d 8b 7d 1a 8d 45 fe  |^.f......}.}..E.|
00000120  8a 4e 0d f7 e1 03 46 fc  13 56 fe b1 04 e8 c2 00  |.N....F..V......|
00000130  72 d7 ea 00 02 70 00 52  50 06 53 6a 01 6a 10 91  |r....p.RP.Sj.j..|
00000140  8b 46 18 a2 26 05 96 92  33 d2 f7 f6 91 f7 f6 42  |.F..&amp;...3......B|
00000150  87 ca f7 76 1a 8a f2 8a  e8 c0 cc 02 0a cc b8 01  |...v............|
00000160  02 80 7e 02 0e 75 04 b4  42 8b f4 8a 56 24 cd 13  |..~..u..B...V$..|
00000170  61 61 72 0a 40 75 01 42  03 5e 0b 49 75 77 c3 03  |aar.@u.B.^.Iuw..|
00000180  18 01 27 0d 0a 49 6e 76  61 6c 69 64 20 73 79 73  |..'..Invalid sys|
00000190  74 65 6d 20 64 69 73 6b  ff 0d 0a 44 69 73 6b 20  |tem disk...Disk |
000001a0  49 2f 4f 20 65 72 72 6f  72 ff 0d 0a 52 65 70 6c  |I/O error...Repl|
000001b0  61 63 65 20 74 68 65 20  64 69 73 6b 2c 20 61 6e  |ace the disk, an|
000001c0  64 20 74 68 65 6e 20 70  72 65 73 73 20 61 6e 79  |d then press any|
000001d0  20 6b 65 79 0d 0a 00 00  49 4f 20 20 20 20 20 20  | key....IO      |
000001e0  53 59 53 4d 53 44 4f 53  20 20 20 53 59 53 7f 01  |SYSMSDOS   SYS..|
000001f0  00 41 bb 00 07 60 66 6a  00 e9 3b ff 00 00 55 aa  |.A...`fj..;...U.|
00000200</pre>
<p>Much better.</p>
<p><strong>4. Copy over OS files to new disk</strong></p>
<p>Now that we have our shiny new bootable floppy, we can copying over the OS from the old floppy:</p>
<pre>david@bt:~$ mktemp -d /tmp/old.XXXXXX
/tmp/old.rvviBJ
david@bt:~$ mktemp -d /tmp/new.XXXXXX
/tmp/new.NFM4WP
david@bt:~$ sudo mount -o loop test.img /tmp/new.NFM4WP/
david@bt:~$ sudo mount -o loop boot98c.IMA /tmp/old.rvviBJ/
david@bt:~$ sudo cp -r /tmp/old.rvviBJ/* /tmp/new.NFM4WP/
david@bt:~$ ls /tmp/new.NFM4WP/
attrib.exe    chkdsk.exe    edit.com    label.exe    scandisk.exe  xcopy32.mod
autoexec.bat  command.com   edit.hlp    mem.exe      scandisk.ini  xcopy.exe
cd1.sys       config.sys    fdisk.exe   move.exe     scanreg.exe
cd2.sys       deltree.exe   format.com  mscdex.exe   smartdrv.exe
cd3.sys       diskcopy.com  himem.sys   msdos.sys    sys.com
cd4.sys       drvspace.bin  io.sys      mtmcdai.sys  xcopy32.exe
david@bt:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
*
/dev/loop0             10M  1.4M  8.7M  14% /tmp/new.NFM4WP
/dev/loop1            1.4M  1.3M   97K  94% /tmp/old.rvviBJ
david@bt:~$ sudo umount /tmp/new.NFM4WP/
david@bt:~$ sudo umount /tmp/old.rvviBJ/</pre>
<p><strong>5. Final configurations for PXELINUX</strong></p>
<p>Remember how I told you to jot down the sector size, number of heads, and sectors per track? Good, because we need it now. To ensure that PXELINUX is aware of the geometry, we need to provide it with the number of sectors per track, amount of heads, and the amount of cylinders the image has. To calculate the amount of cylinders we use the following equation:</p>
<pre>Cylinders = TotalNumberOfSectors / NumberOfHeads / NumberOfSectorsPerTrack</pre>
<p>Since the sector size is 512, we can take the filesystem size in KB from earlier and just double it for the total of 20480 sectors. We then divide that by 64 heads, then divide that by 32 sectors. Our number of cylinders should come out to 10. In your pxelinux config file you&#8217;ll want to put this information in like this:</p>
<pre>label flash_bios
      kernel memdisk
      append initrd=test.img floppy c=10 s=32 h=64</pre>
<p>And there you go, a 10MB bootable floppy image. Hooray!</p>
<p>There&#8217;s a neat script that can do all that we did in this article, available <a href="http://people.cs.uchicago.edu/~gmurali/gui/downloads.html">here</a>. Have fun and happy hacking!</p>
]]></content:encoded>
			<wfw:commentRss>http://failverse.com/creating-a-non-standard-size-bootable-floppy-image-for-pxe-boot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Load balancing with SSL termination</title>
		<link>http://failverse.com/load-balancing-with-ssl-termination/</link>
		<comments>http://failverse.com/load-balancing-with-ssl-termination/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 03:22:46 +0000</pubDate>
		<dc:creator>Ryuujinx</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://failverse.com/?p=302</guid>
		<description><![CDATA[I wrote an article a while back about load balancing with HA Proxy. If you&#8217;re wanting to do SSL, it lets you do it, but SSL will terminate on each individual webhead. This works quite well for performance, and it is designed with performance in mind. Unfortunately there are some cases where you want the [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote an article a <a href="http://failverse.com/load-balancing-with-ha-proxy/">while back</a> about load balancing with HA Proxy. If you&#8217;re wanting to do SSL, it lets you do it, but SSL will terminate on each individual webhead. This works quite well for performance, and it is designed with performance in mind. Unfortunately there are some cases where you want the SSL to terminate on the load balancer (for instance if you&#8217;re making use of the X-Forwarded-For header). This article will explain how to setup Nginx as a load balancer with SSL termination. Read on after the jump for the howto.</p>
<p><span id="more-302"></span></p>
<p>The first thing you&#8217;ll need, is to make sure that your webheads are configured to listen on the internal interface. It can listen on the external as well, but the load balancer is going to communicate to it over the private network. </p>
<pre>
# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      2342/apache2
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2307/sshd
tcp6       0      0 :::22                   :::*                    LISTEN      2307/sshd
</pre>
<p>0.0.0.0 signifies all available IPs, so we&#8217;re fine. If your server is set to explicitly listen on it&#8217;s public IP, you&#8217;ll need to either change it to listen on all or on the internal. </p>
<p>Once we have done this we need to install nginx. The modules we will be using &#8211; upstream and proxy &#8211; are both part of the core HTTP set, so we don&#8217;t need to build it any specific way. You can either grab the source and build it, or just download it from your repository -</p>
<pre> # aptitude install nginx </pre>
<p>Now that we&#8217;ve got this installed, we need to make some configuration changes. First off, go ahead and create a directory to save all your SSL keys in, I&#8217;m going to use <b>/etc/nginx/ssl</b>, feel free to use whatever makes sense to you. Open up /etc/nginx/nginx.conf with your editor of choice and find the http section. Comment out the include for sites-enabled and then create another include, I&#8217;ll be using lb.con &#8211; again, feel free to use whatever you want.</p>
<pre>
user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
}

http {
    include       /etc/nginx/mime.types;

    access_log	/var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
#    include /etc/nginx/sites-enabled/*;
    include /etc/nginx/lb.conf;
}
</pre>
<p>In your new config file, you&#8217;ll need to set up the server and upstream sections. Here is my basic configuration, before we get any further:</p>
<pre>
upstream backend {
	server 10.179.73.92 max_fails=3 fail_timeout=15s;
	server 10.179.73.148 max_fails=3 fail_timeout=15s;
	server 10.179.73.170 max_fails=3 fail_timeout=15s;
	server 10.179.73.197 max_fails=3 fail_timeout=15s;
}

server {
	listen 80;

	location / {
		proxy_pass http://backend;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}
}

server {
	listen 443;
	ssl on;
	ssl_certificate /etc/nginx/ssl/server.crt;
	ssl_certificate_key /etc/nginx/ssl/server.key;

	location / {
		proxy_pass http://backend;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}
}
</pre>
<p>&#8220;upstream&#8221; defines a pool of servers, and basically manages them. You can specify the max times they can fail before they are pulled out of the rotation (I feel 3 is sufficient, you may choose to increase this. You might also want to increase the timeouts, it should be fairly straight forward.)</p>
<p>The second section is what does most of the work &#8211; you need to specify the listen ports, if you have multiple SSL websites that you want to terminate, you will need a server block for each, as well as binding to a specific IP. Additionally you need to make sure the webheads are set up to work with name based virtualhosts, as that header should get based to them. In my case, I only have one SSL website so I simply specify a single listen for 443, and another for 80. </p>
<p>The SSL parts should be fairly straight forward, which leaves the location block &#8211; you can do some pretty cool things with this section, but for our purposes we just want to proxy everything so we use &#8220;/&#8221;. We need to tell it to proxy specifically to port 80, and use the upstream &#8220;backend&#8221;. The last part tells nginx to add the head X-Forwarded-For, which you probably want enabled. </p>
<p><strong>If you want session persistence you have to enable ip_hash in your backend. Simply put &#8220;ip_hash;&#8221; in your upstream block above your servers</strong></p>
<p>More then likely, you&#8217;ll want to fine tune your configuration. For that you might check out the documentation on <a href="http://wiki.nginx.org/HttpProxyModule">proxy</a> as well as <a href="http://wiki.nginx.org/NginxHttpUpstreamModule">upstream</a> as nginx&#8217;s website. </p>
<p>As a final note, you&#8217;re traffic is sent from the load balancer to the webheads in the CLEAR. While this shouldn&#8217;t be a big problem for you in most cases (you can&#8217;t sniff the traffic unless you broadcast it for some reason), it&#8217;s something to keep in mind. The most notable time this might be a problem is on a shared network where you can&#8217;t control it, the biggest problem might be a MiTM attack &#8211; if you&#8217;re concerned about this, you can set up arptables to prevent ARP poisoning, but the best bet would be to just ask your provider. If they don&#8217;t have any kind of ARP poisoning countermeasures in place, you might think about a host with your security as a higher priority. </p>
]]></content:encoded>
			<wfw:commentRss>http://failverse.com/load-balancing-with-ssl-termination/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two Factor Authentication Made Easy: Google-Authenticator</title>
		<link>http://failverse.com/two-factor-authentication-made-easy-google-authenticator/</link>
		<comments>http://failverse.com/two-factor-authentication-made-easy-google-authenticator/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 00:03:34 +0000</pubDate>
		<dc:creator>Ryuujinx</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://failverse.com/?p=297</guid>
		<description><![CDATA[I&#8217;m a pretty big fan of two factor authentication, it lets you secure a server significantly without inconveniencing your users too much. I&#8217;ve used ppp-pam before, and use RSA SecurID for a few things as well, they&#8217;re great implementations. Today it came to my attention that Google had made an authenticator for Google apps account, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a pretty big fan of two factor authentication, it lets you secure a server significantly without inconveniencing your users too much. I&#8217;ve used ppp-pam before, and use RSA SecurID for a few things as well, they&#8217;re great implementations. Today it came to my attention that Google had made an authenticator for Google apps account, but also made a PAM module. It works fairly close to RSA SecurID &#8211; you put in your password, after that works you give it the code that the app on your phone displays, it changes every 30 seconds or so based on it&#8217;s algorithm. </p>
<p>This article is going to cover how to set it up on your own Linux server. I&#8217;ll be doing this on a Debian 6 install, you may need to alter commands, so go ahead and read on after the jump for the how to.</p>
<p><span id="more-297"></span></p>
<p>First off, we need to install the tools to install everything. On Debian this is easily achieved with</p>
<pre> # aptitude install build-essential </pre>
<p>You&#8217;ll also need mercurial to check out the code, and some libraries. </p>
<pre> # aptitude install mercurial libpam-dev </pre>
<p>Additionally if you want to automate setting up your phone&#8217;s app you&#8217;ll want to install the qrencode library -</p>
<pre> # aptitude install libqrencode-dev </pre>
<p>Now we have all the libraries installed, we need to download the source -</p>
<pre> # hg clone https://google-authenticator.googlecode.com/hg/ google-authenticator </pre>
<p>Then after it checks it out, move to the google-authenticator/libpam directory and issue</p>
<pre> # make install </pre>
<p>This will setup the module, and an application to generate your code. Let&#8217;s start with that:</p>
<pre># google-authenticator</pre>
<p>This will first off display a qr code if you have libqrencode installed, alternately you can copy the URL to a browser and display the QR code. Alternately you can manually enter the information, regardless you need to open your phone&#8217;s app and get it added &#8211; the easiest method would be to use the QR code by selecting the add button, then &#8220;scan barcode&#8221;. Use your camera to focus the QR code and it will set up the account for you. Otherwise you need to set it manually using the provided information. You will need to do this for each account on the system.</p>
<p>After your phone is set up, look back at your terminal and answer the questions it asks. Most of them are concerning rate limiting and other security features. Once done, you need to edit two files. The first is to tell pam to use the module:</p>
<pre> # vim /etc/pam.d/common-auth </pre>
<p>In this file add the following line:</p>
<pre> auth    required                        pam_google_authenticator.so </pre>
<p>This tells PAM that it is a required module in order to authenticate. If you plan on using this for SSH (which you probably are), you&#8217;ll also need to allow SSH to send challenge requests:</p>
<pre> # vim /etc/ssh/sshd_config </pre>
<p>Fine the Challenge Response Authentication line and set it to yes:</p>
<pre> ChallengeResponseAuthentication yes </pre>
<p>Once this is done, restart SSH and open a NEW shell to test your change:</p>
<pre># ssh root@10.1.1.20
Password:
Verification code:
Linux Sharaa 2.6.32-5-xen-amd64 #1 SMP Thu May 19 01:16:47 UTC 2011 x86_64
</pre>
<p>Hopefully it all works and you&#8217;ll be able to enjoy your two factor authentication. </p>
]]></content:encoded>
			<wfw:commentRss>http://failverse.com/two-factor-authentication-made-easy-google-authenticator/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using your own OS on Cloud Servers</title>
		<link>http://failverse.com/using-your-own-os-on-cloud-servers/</link>
		<comments>http://failverse.com/using-your-own-os-on-cloud-servers/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 23:38:45 +0000</pubDate>
		<dc:creator>Ryuujinx</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Rackspace Cloud]]></category>

		<guid isPermaLink="false">http://failverse.com/?p=269</guid>
		<description><![CDATA[I see complaints across twitter and the feedback page, as well as various blog posts about how the Rackspace Cloud doesn&#8217;t support this OS, or that OS. With the introduction of PV-Grub, you should be able to run nearly any OS you want &#8211; with a bit of work. Keep in mind, this process is [...]]]></description>
			<content:encoded><![CDATA[<p>I see complaints across twitter and the feedback page, as well as various blog posts about how the <a href="http://rackspacecloud.com">Rackspace Cloud</a> doesn&#8217;t support this OS, or that OS. With the introduction of PV-Grub, you should be able to run nearly any OS you want &#8211; with a bit of work.</p>
<p>Keep in mind, this process is entirely unsupported by Rackspace. If your OS breaks on you, and you&#8217;re using some OS no one has heard of, they&#8217;ll be hard pressed to support it.</p>
<p>For this process you will need the following:</p>
<ul>
<li>A Tar archive of the filesystem for the OS you want to use, excluding /proc, /sys and /dev</li>
<li>The New Cloud Server</li>
<li>A good understanding of the OS you want to use.</li>
</ul>
<p>For my example, I will be using Suse 11.3, it should work the same for other OSes.  Let&#8217;s go ahead and get right into it.</p>
<p><span id="more-269"></span></p>
<h2>Step1 &#8211; making your tar image</h2>
<p>The first thing you&#8217;ll have to do is boot into the OS you want to use. My method for this, was to use my home computer and use <a href="http://www.virtualbox.org/">Virtualbox</a> to boot into a 64bit VM, and proceeded to install Suse11.3. Once in the VM, I switched to the root user and ran</p>
<pre>tar -cf / suse.tar --exclude "/bin" --exclude "/proc" --exclude "/sys"</pre>
<p>While this ran, I watched some shows on my new <a href="http://www.boxee.tv/">BoxeeBox</a> (you should get one too, they&#8217;re awesome).</p>
<p><strong>A Note about VMs and 64Bit: You need a recent Processor that supports virtualization technology, VT-x , if your personal computer does not support this, see if a friend can help you out.</strong></p>
<p>After it finished, I ran</p>
<pre>scp suse.tar root@suse-staging.failverse.com:suse.tar</pre>
<p>And let it ran. This took me at least a couple hours, due to only having a couple Mbits up on my home connection.</p>
<h2>Step 2: Rescue Mode and Things to do!</h2>
<p>Now that your image is finally uploaded, you will boot your server into rescue mode. This brings up a new server along side it, and emails you a temporary root password. As it uses the same IP and has different keys, you might need to delete a line out of known_hosts before you can connect.</p>
<p>First, you will need to mount your server&#8217;s drive. I use the /mnt directory, feel free to mount it wherever you feel.</p>
<pre> mount /dev/sda1 /mnt</pre>
<p>Inside of the drive you&#8217;ll want to make backups of your tar, dev, proc and sys.</p>
<pre> mkdir stuff
mv /root/suse.tar stuff
mv dev stuff
mv proc stuff
mv sys styff
mv stuff /
</pre>
<p>Now delete everything from the drive.</p>
<pre> rm -rf /mnt/*</pre>
<p>Now lets take the tar and extract everything into the drive.</p>
<pre>mv /stuff/suse.tar /mnt/
tar -xvf suse.tar
</pre>
<p>After this, move your old directories back -</p>
<pre>mv /stuff/* /mnt/
</pre>
<p>And finally, we need to edit some things.</p>
<p>In <strong>/etc/resolv.conf</strong><br />
For DFW servers:</p>
<pre>
nameserver 72.3.128.240
nameserver 72.3.128.241
</pre>
<p>for ORD servers:</p>
<pre>
nameserver 173.203.4.8
nameserver 173.203.4.9
</pre>
<p>In <strong>/etc/fstab</strong></p>
<pre>proc            /proc       proc    defaults    0 0
/dev/sda1       /           ext3    defaults,errors=remount-ro,noatime    0 1
/dev/sda2       none        swap    sw          0 0
</pre>
<p>You will also need to edit your interface scripts, for Suse these are found in /etc/sysconfig/network</p>
<p><strong>ifcfg-eth0</strong></p>
<pre>BOOTPROTO='static'
IPADDR='YOURSERVERPUBLICIP'
NETMASK='255.255.255.0'
STARTMODE='auto'
USERCONTROL='no'
</pre>
<p><strong>ifcfg-eth1</strong></p>
<pre>BOOTPROTO='static'
IPADDR='YOURSERVERINTERNALIP'
NETMASK='255.255.224.0'
STARTMODE='auto'
USERCONTROL='no'
</pre>
<p>After that, you will need to set up your IP routes,</p>
<p>My routes looked like this:</p>
<pre>#Destination    Gateway        Mask           Device

173.203.218.0   0.0.0.0        255.255.255.0  eth0
10.177.160      0.0.0.0        255.255.224.0  eth1
10.191.192.0    10.177.160.1   255.255.192.0  eth1
10.176.0.0      10.177.160.1   255.248.0.0    eth1
default         173.203.218.1  0.0.0.0        eth0
</pre>
<p>The second two destinations seem to always be the same for eth1, the gateway for them is the first eth1 entry ending in a .1 octet. If your internal network doesn&#8217;t work after a reboot, check what the distro set your route too &#8211; the internal Ip of this server was 10.177.164.x, but it didn&#8217;t work unless I used that route.</p>
<p>Now that you&#8217;re route is set, make sure SSH is set to start on startup, and exit rescue mode.</p>
<p>If all went well, you&#8217;ll be able to SSH to your new OS and be good to go &#8211; though you may need to tweak settings here and there. If your OS needs a custom kernel, make sure your kernel and grub are configured, and go through my <a href="http://failverse.com/setting-up-pv-grub-cloud-servers/">PV-Grub</a> article. </p>
]]></content:encoded>
			<wfw:commentRss>http://failverse.com/using-your-own-os-on-cloud-servers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Compiling kernel modules for a Rackspace Cloud Server</title>
		<link>http://failverse.com/compiling-kernel-modules-for-a-rackspace-cloud-server/</link>
		<comments>http://failverse.com/compiling-kernel-modules-for-a-rackspace-cloud-server/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 05:00:25 +0000</pubDate>
		<dc:creator>Coolj</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Rackspace Cloud]]></category>

		<guid isPermaLink="false">http://failverse.com/?p=249</guid>
		<description><![CDATA[To compile kernel modules on a Cloud Server you need to complete the following steps, making sure to change the kernel version and directories where appropriate (&#8211;for example, 2.6.33.5-rscloud extracts to linux-2.6.33.5, whereas 2.6.35.4-rscloud extracts to 2.6.35.4-rscloud). Grab the patched kernel source for your kernel from the repository (check your kernel version with uname -a). [...]]]></description>
			<content:encoded><![CDATA[<p>To compile kernel modules on a Cloud Server you need to complete the following steps, making sure to change the kernel version and directories where appropriate (&#8211;for example, 2.6.33.5-rscloud extracts to linux-2.6.33.5, whereas 2.6.35.4-rscloud extracts to 2.6.35.4-rscloud).</p>
<p><span id="more-249"></span></p>
<ol>
<li>Grab the patched kernel source for your kernel from <a href="http://kernel.slicehost.com">the repository</a> (check your kernel version with uname -a).
<pre><code>wget http://kernel.slicehost.com/2.6.35.4-rscloud/patched_source/2.6.35.4-rscloud.tar.gz</code></pre>
</li>
<li>Extract the kernel to /usr/src.
<pre><code>sudo tar xpf 2.6.35.4-rscloud.tar.gz -C /usr/src</code></pre>
</li>
<li>Create a link to /usr/src/linux and link to build in /lib/modules
<pre><code>sudo rm -rf /usr/src/linux
sudo ln -s /usr/src/2.6.35.4-rscloud /usr/src/linux
sudo rm -rf /lib/modules/2.6.35.4-rscloud/build
sudo ln -s /usr/src/linux /lib/modules/2.6.35.4-rscloud/build</code></pre>
</li>
<li>Create the configuration file and prepare the modules
<pre><code>zcat /proc/config.gz | sudo tee /usr/src/linux/.config &gt; /dev/null
sudo make oldconfig
sudo make modules_prepare
sudo make INSTALL_HDR_PATH=/usr headers_install
</code></pre>
</li>
</ol>
<p>If all went well you can now build custom kernel modules.</p>
]]></content:encoded>
			<wfw:commentRss>http://failverse.com/compiling-kernel-modules-for-a-rackspace-cloud-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating backups for Cloud Servers larger than 2GB</title>
		<link>http://failverse.com/creating-backups-for-cloud-servers-larger-than-2gb/</link>
		<comments>http://failverse.com/creating-backups-for-cloud-servers-larger-than-2gb/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 00:08:17 +0000</pubDate>
		<dc:creator>Judinous</dc:creator>
				<category><![CDATA[Rackspace Cloud]]></category>

		<guid isPermaLink="false">http://failverse.com/?p=227</guid>
		<description><![CDATA[According to the website, backups for Cloud Servers are only available for instances with a memory size of 2GB or less.  However, this restriction only applies to (some of) the control panel, and not the API itself.  It is still quite possible to take snapshots of your larger servers, though there are a few caveats [...]]]></description>
			<content:encoded><![CDATA[<p>According to the website, backups for Cloud Servers are only available for instances with a memory size of 2GB or less.  However, this restriction only applies to (some of) the control panel, and not the API itself.  It is still quite possible to take snapshots of your larger servers, though there are a few caveats along the way.</p>
<p>To take snapshots of your &gt;2GB Cloud Servers through the control panel, you first need to go to Hosting -&gt; Cloud Servers and click on the &#8220;My Server Images&#8221; tab.  Note that you do <strong>not</strong> want to go to an individual server&#8217;s overview page to take the image;  it will not work for &gt;2GB servers.</p>
<p><span id="more-227"></span></p>
<p><a href="http://failverse.com/wp-content/uploads/2010/11/backups-1.png"><img class="alignnone size-full wp-image-229" title="backups-1" src="http://failverse.com/wp-content/uploads/2010/11/backups-1.png" alt="" width="640" height="380" /></a></p>
<p>Just hit the &#8220;New Image&#8221; button on this page and you can select any of your servers from the list.  In this case, I will take a backup of my 4GB server called &#8220;sinatra&#8221;.</p>
<p><a href="http://failverse.com/wp-content/uploads/2010/11/backups-4.png"><img class="alignnone size-full wp-image-235" title="backups-4" src="http://failverse.com/wp-content/uploads/2010/11/backups-4.png" alt="" width="460" height="415" /></a></p>
<p>Pick a name for your image (I called mine &#8220;sinatra-backup&#8221;), wait for it to complete, and voila: you have a backup of your &gt;2GB server.</p>
<p><a href="http://failverse.com/wp-content/uploads/2010/11/backups-31.png"><img class="alignnone size-full wp-image-233" title="backups-3" src="http://failverse.com/wp-content/uploads/2010/11/backups-31.png" alt="" width="680" height="190" /></a></p>
<p>You can also create backups for &gt;2GB servers directly through the API.  You can use the script in <a href="http://failverse.com/automating-cloud-servers-backups/">this earlier Failverse blog post</a> to create backups of your servers as well;  simply run the script directly instead of putting it in a cron job.</p>
<p><strong>Caveats</strong></p>
<p>Although you can use the two aforementioned methods to create backups of &gt;2GB servers, there are a number of restrictions still in place.</p>
<p>Linux:</p>
<ul>
<li>The total amount of disk space currently used cannot be higher than 75GB.  You can check how much space you are using with the &#8220;df -h&#8221; command.</li>
<li>The total number of inodes in use cannot exceed 3 million.  You can check how many inodes are in use with the &#8220;df -i&#8221; command.  If your inode usage is inordinately high, deleting unnecessary files (generally log files or stale connections are the culprit here) or temporarily zipping up multiple files into tarballs will reduce your usage.</li>
<li>If it takes longer than 2 hours for the file transfer portion of the backup to finish, it will fail.  This may occur if you have a large amount of both disk space and inodes in use, though not enough to trigger the hard caps.  Reducing your inode usage can help reduce the time it takes to perform the backup.</li>
</ul>
<p>Windows:</p>
<ul>
<li>The total size of the sparce disk file that your virtual hard disk resides upon cannot be larger than 160GB.  What this means is that the <em>highest amount of disk space in use at one time in your server&#8217;s history</em> cannot have exceeded 160GB.  If you were using more disk space than that in the past, you are basically SOL;  the only way to make a backup image is to copy your data to a new server (assuming you have &lt;160GB in use currently) and then take a snapshot of that new machine.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://failverse.com/creating-backups-for-cloud-servers-larger-than-2gb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

