<?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>Cain Manor &#187; UNIX</title> <atom:link href="http://cainmanor.com/category/tech/unix/feed/" rel="self" type="application/rss+xml" /><link>http://cainmanor.com</link> <description>Your Guide To All Things Cain™</description> <lastBuildDate>Thu, 17 May 2012 19:43:34 +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>Push SSH public keys to multiple host</title><link>http://cainmanor.com/tech/push-ssh-public-keys-to-mulitple-host/</link> <comments>http://cainmanor.com/tech/push-ssh-public-keys-to-mulitple-host/#comments</comments> <pubDate>Tue, 02 Aug 2011 18:27:52 +0000</pubDate> <dc:creator>Greg Cain</dc:creator> <category><![CDATA[OS-X]]></category> <category><![CDATA[Tech]]></category> <category><![CDATA[UNIX]]></category> <category><![CDATA[Work]]></category><guid
isPermaLink="false">http://cainmanor.com/?p=1251</guid> <description><![CDATA[I&#8217;m starting a new job where I need to have my SSH keys pushed to hundreds of Red Hat servers. The special sauce is a command called ssh-copy-id. However, using this command requires you answering a (yes/no) question, then shortly thereafter enter your password. Painful. Here&#8217;s how push your keys without the pain. The first [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;m starting a new job where I need to have my SSH keys pushed to hundreds of Red Hat servers. The special sauce is a command called ssh-copy-id.  However, using this command requires you answering a (yes/no) question, then shortly thereafter enter your password.  Painful. Here&#8217;s how push your keys without the pain.<br
/> <span
id="more-1251"></span><br
/> The first problem is having to answer (yes/no) for each server.  Normally you see this&#8230;</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">The authenticity of host <span style="color: #ff0000;">'myfirsthost.work.cainmanor.com (10.256.33.106)'</span> can<span style="color: #ff0000;">'t be established.
RSA key fingerprint is fc:40:7c:de:b8:ac:a2:f5:d4:11:d0:0e:b2:77:8a:63.
Are you sure you want to continue connecting (yes/no)? yes</span></pre></div></div><p>To stop this prompt, we need to edit your ~/.ssh/config file.  Add these two lines</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">StrictHostKeyChecking no
<span style="color: #007800;">UserKnownHostsFile</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div><p>Setting your UserKnownHostsFile should only be a temporary fix.  After you&#8217;ve pushed your keys, you should comment out both of those settings.</p><p>Your password is the next problem.  We can solve that with sshpass.  sshpass takes your password and passes it on when ssh ask for it.  There are three ways to do it, all of them insecure.  Read the man page and decide which of those you want to use.  For my purposes I just put it on the command line &#8211; I&#8217;m on my personal machine with no other users, and only I know the passwords to the box.  Don&#8217;t do this on a shared server.</p><p>Here is an example of how to push your public key one.  Try it on a new server to make sure you get the results you expect.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">sshpass <span style="color: #660033;">-p</span> <span style="color: #ff0000;">'MY_PASSWORD'</span> ssh-copy-id gregc<span style="color: #000000; font-weight: bold;">@</span>new_host_with_no_keys</pre></div></div><p>Now that we&#8217;ve got the prompts turned off, we&#8217;ll wrap a script around this.  How you get the list of appropriate hostnames or IP&#8217;s is your business.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> X <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> my_host_that_need_keys<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">do</span>
sshpass <span style="color: #660033;">-p</span> <span style="color: #ff0000;">'MY_PASSWORD'</span> ssh-copy-id gregc<span style="color: #000000; font-weight: bold;">@</span><span style="color: #800000;">${X}</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div><p>Happy Computing!!</p> ]]></content:encoded> <wfw:commentRss>http://cainmanor.com/tech/push-ssh-public-keys-to-mulitple-host/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Installing APC (Alternative PHP Cache) on CentOS 5.6</title><link>http://cainmanor.com/tech/installing-apc-alternative-php-cache-on-centos-5-6/</link> <comments>http://cainmanor.com/tech/installing-apc-alternative-php-cache-on-centos-5-6/#comments</comments> <pubDate>Tue, 12 Jul 2011 02:12:04 +0000</pubDate> <dc:creator>Greg Cain</dc:creator> <category><![CDATA[Online]]></category> <category><![CDATA[Tech]]></category> <category><![CDATA[UNIX]]></category><guid
isPermaLink="false">http://cainmanor.com/?p=1248</guid> <description><![CDATA[There were more than a few instructions on how to do this. They were all wrong, at least for my default install of CentOS 5.6. In a nutshell, here is how I was able to do it: cd /tmp yum install pcre-devel wget http://pecl.php.net/get/APC-3.1.9.tgz tar -xvf APC-3.1.9.tgz cd APC-3.1.9 phpize whereis php-config ./configure –enable-apc –enable-apc-mmap [...]]]></description> <content:encoded><![CDATA[<p>There were more than a few instructions on how to do this.  They were all wrong, at least for my default install of CentOS 5.6.</p><p>In a nutshell, here is how I was able to do it:<br
/> <span
id="more-1248"></span></p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
yum <span style="color: #c20cb9; font-weight: bold;">install</span> pcre-devel
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>pecl.php.net<span style="color: #000000; font-weight: bold;">/</span>get<span style="color: #000000; font-weight: bold;">/</span>APC-3.1.9.tgz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvf</span> APC-3.1.9.tgz
<span style="color: #7a0874; font-weight: bold;">cd</span> APC-3.1.9
phpize
<span style="color: #c20cb9; font-weight: bold;">whereis</span> php-config
.<span style="color: #000000; font-weight: bold;">/</span>configure –enable-apc –enable-apc-mmap –with-apxs –with-php <span style="color: #007800;">config</span>=<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>php-config
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;extension=apc.so&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.d<span style="color: #000000; font-weight: bold;">/</span>apc.ini
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;apc.slam_defense=0&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.d<span style="color: #000000; font-weight: bold;">/</span>apc.ini
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;apc.write_lock=1&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.d<span style="color: #000000; font-weight: bold;">/</span>apc.ini
service httpd restart</pre></div></div><p>I also make these changes to my httpd.conf file</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">Timeout <span style="color: #000000;">40</span>
KeepAlive On
MaxKeepAliveRequests <span style="color: #000000;">200</span>
KeepAliveTimeout <span style="color: #000000;">2</span></pre></div></div>]]></content:encoded> <wfw:commentRss>http://cainmanor.com/tech/installing-apc-alternative-php-cache-on-centos-5-6/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Install Django on OS-X Snow Leopard using sqlite3</title><link>http://cainmanor.com/tech/install-django-on-os-x-snow-leopard-using-sqlite3/</link> <comments>http://cainmanor.com/tech/install-django-on-os-x-snow-leopard-using-sqlite3/#comments</comments> <pubDate>Sun, 09 Jan 2011 01:40:29 +0000</pubDate> <dc:creator>Greg Cain</dc:creator> <category><![CDATA[Online]]></category> <category><![CDATA[Tech]]></category> <category><![CDATA[UNIX]]></category><guid
isPermaLink="false">http://cainmanor.com/?p=1213</guid> <description><![CDATA[Download django.   It should default to your ~/Downloads folder and it should be untarred. Go into that directory (in my case, /Users/gregcain/Downloads/Django-1.2.4), and install Django. sudo python setup.py install Now we need to configure our first project, which we&#8217;ll call myBooks. Create the parent directory you want your project to live in. mkdir ~/Django [...]]]></description> <content:encoded><![CDATA[<p>Download <a
href="http://www.djangoproject.com/download/">django</a>.   It should default to your ~/Downloads folder and it should be untarred.  Go into that directory (in my case, /Users/gregcain/Downloads/Django-1.2.4), and install Django.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div><p><span
id="more-1213"></span><br
/> Now we need to configure our first project, which we&#8217;ll call myBooks.  Create the parent directory you want your project to live in.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>Django</pre></div></div><p>Let&#8217;s create the first project</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">django-admin.py startproject myBooks</pre></div></div><p>You&#8217;ll see a directory created underneath your Django directory called myBooks. (~/Django/myBooks)  In that directory, you&#8217;ll see the following files&#8230;</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">__init__.py
manage.py
settings.py
urls.py</pre></div></div><p>Start the built in web server.  From the directory ~/Django/myBooks directory</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">python manage.py runserver</pre></div></div><p>Which gives you this..</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">Django version 1.2.4, using settings <span style="color: #ff0000;">'myBooks.settings'</span>
Development server is running at http:<span style="color: #000000; font-weight: bold;">//</span>127.0.0.1:<span style="color: #000000;">8000</span><span style="color: #000000; font-weight: bold;">/</span>
Quit the server with CONTROL-C.</pre></div></div><p>If you point your web browser to http://127.0.0.1:8000/ you should see this basic getting started page<br
/> <a
href="http://photos.cainmanor.com/2011/01/Screen-shot-2011-01-08-at-4.21.39-PM.png" rel="lightbox[1213]"><img
src="http://photos.cainmanor.com/2011/01/Screen-shot-2011-01-08-at-4.21.39-PM.png" alt="" title="Django getting started web view" width="869" height="280" class="alignnone size-full wp-image-1214" /></a><br
/> If you see that, all is good so far&#8230;</p><p>Now let&#8217;s configure Django to use sqlite as it&#8217;s database.  All you need to do is edit the settings.py file in ~/Django/myBooks.  You need to change ENGINE to the sqlite3 instance, and tell it where you want your database to live.  You&#8217;ll create that database in the next step.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">DATABASES = <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #ff0000;">'default'</span>: <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #ff0000;">'ENGINE'</span>: <span style="color: #ff0000;">'django.db.backends.sqlite3'</span>, <span style="color: #666666; font-style: italic;"># Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.</span>
        <span style="color: #ff0000;">'NAME'</span>: <span style="color: #ff0000;">'/Users/gregcain/Django/myBooks/myBooksDB'</span>,                      <span style="color: #666666; font-style: italic;"># Or path to database file if using sqlite3.</span>
        <span style="color: #ff0000;">'USER'</span>: <span style="color: #ff0000;">''</span>,                      <span style="color: #666666; font-style: italic;"># Not used with sqlite3.</span>
        <span style="color: #ff0000;">'PASSWORD'</span>: <span style="color: #ff0000;">''</span>,                  <span style="color: #666666; font-style: italic;"># Not used with sqlite3.</span>
        <span style="color: #ff0000;">'HOST'</span>: <span style="color: #ff0000;">''</span>,                      <span style="color: #666666; font-style: italic;"># Set to empty string for localhost. Not used with sqlite3.</span>
        <span style="color: #ff0000;">'PORT'</span>: <span style="color: #ff0000;">''</span>,                      <span style="color: #666666; font-style: italic;"># Set to empty string for default. Not used with sqlite3.</span>
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div><p>Now create the database</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">python manage.py syncdb</pre></div></div><p>You&#8217;ll be asked a few questions, including one to setup a super user.</p><p>Now that the database is created, let&#8217;s go in and see if it looks correct.  To open a connection to the database</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">sqlite3 myBooksDB</pre></div></div><p>and to see the schema</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">.schema</pre></div></div><p>Happy Coding!!</p> ]]></content:encoded> <wfw:commentRss>http://cainmanor.com/tech/install-django-on-os-x-snow-leopard-using-sqlite3/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Basic Samba-Active Directory troubleshooting using wbinfo</title><link>http://cainmanor.com/tech/basic-samba-active-directory-troubleshooting-using-wbinfo/</link> <comments>http://cainmanor.com/tech/basic-samba-active-directory-troubleshooting-using-wbinfo/#comments</comments> <pubDate>Wed, 08 Sep 2010 19:25:39 +0000</pubDate> <dc:creator>Greg Cain</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[UNIX]]></category> <category><![CDATA[Windows]]></category><guid
isPermaLink="false">http://cainmanor.com/?p=1146</guid> <description><![CDATA[This document is intended to step you through some of the basics of troubleshooting samba connectivity with your domain controller, using wbinfo.   This is not intended to show you how to configure Samba to talk to your domain controller.  Others have done a much better job that I can. winbind must be running in [...]]]></description> <content:encoded><![CDATA[<p>This document is intended to step you through some of the basics of troubleshooting samba connectivity with your domain controller, using wbinfo.   This is not intended to show you how to configure Samba to talk to your domain controller.  Others have done a much better job that I can.</p><p>winbind must be running in order for wbinfo to work, and you need to be connected to your domain.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">wbinfo <span style="color: #660033;">-p</span>
Ping to winbindd succeeded on fd <span style="color: #000000;">4</span></pre></div></div><p>A simple ping test to see if your DC is alive</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">wbinfo <span style="color: #660033;">-t</span>
checking the trust secret via RPC calls succeeded</pre></div></div><p>Verify that the workstation trust account created when the Samba server is added to the Windows NT domain is working.  This is a good first step to make sure you can talk to your DC<br
/> <span
id="more-1146"></span></p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">wbinfo <span style="color: #660033;">-u</span></pre></div></div><p>This will list your domain users.   Make sure the users you expect are there</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">wbinfo <span style="color: #660033;">-a</span> greg.cain<span style="color: #000000; font-weight: bold;">%</span>password</pre></div></div><p>This is an easy way to check that your user can authenticate against the domain.  However, I&#8217;d recommend against using it since it will show your password on the command line, in your history, and in the ps command if it&#8217;s executed at the right time (there are many other reasons, but those should be enough to dissuade you.)  Use a dummy account if possible.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">wbinfo <span style="color: #660033;">-g</span></pre></div></div><p>Show a list of domain groups.   Again, make sure the groups you expect are present.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">wbinfo <span style="color: #660033;">-n</span> greg.cain
S-<span style="color: #000000;">1</span>-<span style="color: #000000;">5</span>-<span style="color: #000000;">21</span>-XXXX789314-<span style="color: #000000;">3545391909</span>-<span style="color: #000000;">2802175779</span>-XXXX User <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div><p>This will get you the SID for the user you&#8217;ve specified (greg.cain in this case.)</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">wbinfo <span style="color: #660033;">-s</span> S-<span style="color: #000000;">1</span>-<span style="color: #000000;">5</span>-<span style="color: #000000;">21</span>-XXXX789314-<span style="color: #000000;">3545391909</span>-<span style="color: #000000;">2802175779</span>-XXXX
DOMAIN\greg.cain</pre></div></div><p>Using the SID you just returned, let&#8217;s make sure the reverse mappings are correct.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">wbinfo <span style="color: #660033;">-r</span> greg.cain
16XXX216
16XXX217
....</pre></div></div><p>This will show a list of groups that the user greg.cain belongs to.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">wbinfo <span style="color: #660033;">-G</span> 16XXX217
S-<span style="color: #000000;">1</span>-<span style="color: #000000;">5</span>-<span style="color: #000000;">21</span>-<span style="color: #000000;">1540789314</span>-<span style="color: #000000;">3545391909</span>-<span style="color: #000000;">2802175779</span>-YYY</pre></div></div><p>This converts the GID to the SID.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">wbinfo <span style="color: #660033;">-Y</span> S-<span style="color: #000000;">1</span>-<span style="color: #000000;">5</span>-<span style="color: #000000;">21</span>-<span style="color: #000000;">1540789314</span>-<span style="color: #000000;">3545391909</span>-<span style="color: #000000;">2802175779</span>-YYY
16XXX217</pre></div></div><p>This is the reverse mapping of the SID to the GID</p> ]]></content:encoded> <wfw:commentRss>http://cainmanor.com/tech/basic-samba-active-directory-troubleshooting-using-wbinfo/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Setup logging for Varnish &#8211; The right way</title><link>http://cainmanor.com/tech/setup-logging-for-varnish-the-right-way/</link> <comments>http://cainmanor.com/tech/setup-logging-for-varnish-the-right-way/#comments</comments> <pubDate>Fri, 30 Jul 2010 02:45:45 +0000</pubDate> <dc:creator>Greg Cain</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[UNIX]]></category><guid
isPermaLink="false">http://cainmanor.com/?p=1125</guid> <description><![CDATA[Initially, logging Varnish didn&#8217;t really work that well. Varnish, by default, doesn&#8217;t log (varnishncsa can do some logging, but I haven&#8217;t figured that out yet.) I&#8217;ve been parsing my logs with JAWstats, which reads the Apache logs. However, by default, varnish will replace the IP address of the originating client with the IP address of [...]]]></description> <content:encoded><![CDATA[<p>Initially, logging Varnish didn&#8217;t really work that well.  Varnish, by default, doesn&#8217;t log (varnishncsa can do some logging, but I haven&#8217;t figured that out yet.)  I&#8217;ve been parsing my logs with JAWstats, which reads the Apache logs.  However, by default, varnish will replace the IP address of the originating client with the IP address of the proxy server, meaning all traffic will look like it comes from my single server.  This is what an entry looks like</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">173.230.157.240 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>Jul<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>:<span style="color: #000000;">15</span>:<span style="color: #000000;">47</span>:<span style="color: #000000;">47</span> -0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET / HTTP/1.1&quot;</span> <span style="color: #000000;">200</span> <span style="color: #000000;">20046</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;Pingdom.com_bot_version_1.4_(http://www.pingdom.com/)&quot;</span>
173.230.157.240 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>Jul<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>:<span style="color: #000000;">15</span>:<span style="color: #000000;">47</span>:<span style="color: #000000;">48</span> -0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET / HTTP/1.1&quot;</span> <span style="color: #000000;">200</span> <span style="color: #000000;">20046</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;Pingdom.com_bot_version_1.4_(http://www.pingdom.com/)&quot;</span>
173.230.157.240 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>Jul<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>:<span style="color: #000000;">15</span>:<span style="color: #000000;">47</span>:<span style="color: #000000;">49</span> -0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET / HTTP/1.1&quot;</span> <span style="color: #000000;">200</span> <span style="color: #000000;">20046</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;Pingdom.com_bot_version_1.4_(http://www.pingdom.com/)&quot;</span>
173.230.157.240 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>Jul<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>:<span style="color: #000000;">15</span>:<span style="color: #000000;">47</span>:<span style="color: #000000;">50</span> -0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET / HTTP/1.1&quot;</span> <span style="color: #000000;">200</span> <span style="color: #000000;">20046</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;Pingdom.com_bot_version_1.4_(http://www.pingdom.com/)&quot;</span>
Yeah, I made this up, but you get the idea.</pre></div></div><p>That&#8217;s no good.   How will I tell that I&#8217;m famous in Sweden?  I found a way to get the client IP information passed to the backend<br
/> <span
id="more-1125"></span></p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">sub vcl_recv <span style="color: #7a0874; font-weight: bold;">&#123;</span>
       remove req.http.X-Forwarded-For;
       <span style="color: #000000; font-weight: bold;">set</span>    req.http.X-Forwarded-For = client.ip;
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div><p>This is what we get from this.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">207.218.231.170, 207.218.231.170 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>Jul<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>:<span style="color: #000000;">15</span>:<span style="color: #000000;">47</span>:<span style="color: #000000;">47</span> -0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET / HTTP/1.1&quot;</span> <span style="color: #000000;">200</span> <span style="color: #000000;">20046</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;Pingdom.com_bot_version_1.4_(http://www.pingdom.com/)&quot;</span></pre></div></div><p>Ok, this is better, but the IP address is duplicated.  I don&#8217;t know if it causes trouble with JAWstats (I assume it does), but I know that it is ugly to me.  After much <a
href="https://wiki.fourkitchens.com/display/PF/Workaround+for+Varnish+X-Forwarded-For+bug">googling</a>, I found this…</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">sub vcl_recv <span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #666666; font-style: italic;"># 	Rename the incoming XFF header to work around a Varnish bug.</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>req.http.X-Forwarded-For<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #666666; font-style: italic;">#	Append the client IP</span>
    <span style="color: #000000; font-weight: bold;">set</span> req.http.X-Real-Forwarded-For = req.http.X-Forwarded-For <span style="color: #ff0000;">&quot;, &quot;</span> regsub<span style="color: #7a0874; font-weight: bold;">&#40;</span>client.ip, <span style="color: #ff0000;">&quot;:.*&quot;</span>, <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
    <span style="color: #7a0874; font-weight: bold;">unset</span> req.http.X-Forwarded-For;
  <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">//</span> Simply use the client IP
    <span style="color: #000000; font-weight: bold;">set</span> req.http.X-Real-Forwarded-For = regsub<span style="color: #7a0874; font-weight: bold;">&#40;</span>client.ip, <span style="color: #ff0000;">&quot;:.*&quot;</span>, <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
  <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div><p>And finally we have a working log file.</p><p>This is the first log file from this server</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">82.103.128.63 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span>04<span style="color: #000000; font-weight: bold;">/</span>Jul<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>:03:<span style="color: #000000;">57</span>:<span style="color: #000000;">47</span> -0400<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET / HTTP/1.0&quot;</span> <span style="color: #000000;">200</span> <span style="color: #000000;">23301</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;Pingdom.com_bot_version_1.4_(http://www.pingdom.com/)&quot;</span></pre></div></div><p>And this is the last</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">24.19.50.69 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>Jul<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">44</span>:<span style="color: #000000;">18</span> -0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;POST /wp-admin/admin-ajax.php HTTP/1.1&quot;</span> <span style="color: #000000;">200</span> <span style="color: #000000;">177</span> <span style="color: #ff0000;">&quot;http://cainmanor.com/wp-admin/post-new.php&quot;</span> <span style="color: #ff0000;">&quot;Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16&quot;</span></pre></div></div>]]></content:encoded> <wfw:commentRss>http://cainmanor.com/tech/setup-logging-for-varnish-the-right-way/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 4/8 queries in 0.005 seconds using disk: basic
Object Caching 408/414 objects using disk: basic

Served from: cainmanor.com @ 2012-05-19 14:56:22 -->
