<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="/assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>while not keypressed (Posts about ubuntu)</title><link>https://www.keypressure.com/</link><description></description><atom:link href="https://www.keypressure.com/blog/tags/ubuntu.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><lastBuildDate>Thu, 23 Oct 2025 15:54:38 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Subpixel rendering in Fedora 22</title><link>https://www.keypressure.com/blog/subpixel-rendering-in-fedora-22/</link><dc:creator>Roman Yepishev</dc:creator><description>&lt;p&gt;I've spent last week trying to get subpixel rendering working with fedora's freetype package, and even though it had the patch...&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="gd"&gt;--- freetype-2.5.2/include/config/ftoption.h 2013-12-08 19:40:19.000000000 +0100&lt;/span&gt;
&lt;span class="gi"&gt;+++ freetype-2.5.2-enable-spr/include/config/ftoption.h 2014-01-17 19:17:34.000000000 +0100&lt;/span&gt;
&lt;span class="gu"&gt;@@ -92,7 +92,7 @@&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;  /* This is done to allow FreeType clients to run unmodified, forcing     */
&lt;span class="w"&gt; &lt;/span&gt;  /* them to display normal gray-level anti-aliased glyphs.                */
&lt;span class="w"&gt; &lt;/span&gt;  /*                                                                       */
&lt;span class="gd"&gt;-  /* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */&lt;/span&gt;
&lt;span class="gi"&gt;+  #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING&lt;/span&gt;


&lt;span class="w"&gt; &lt;/span&gt;  /*************************************************************************/
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;... the fonts still looked horribly (e.g. &lt;a href="https://diasp.org/uploads/images/scaled_full_159fbad93ab20fe4615b.png"&gt;this web page&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;Today I actually &lt;strong&gt;read&lt;/strong&gt; the spec file, and it started with...&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;#&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Patented&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;subpixel&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rendering&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;disabled&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;by&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
#&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Pass&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;'--with subpixel_rendering'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;on&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rpmbuild&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nb"&gt;line&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;enable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="c"&gt;%{!?_with_subpixel_rendering: %{!?_without_subpixel_rendering: %define _without_subpixel_rendering --without-subpixel_rendering}}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;insert a minute of swearing&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Everybody seem to be all hyped about &lt;a href="http://www.infinality.net/blog/infinality-freetype-patches/"&gt;infinality&lt;/a&gt; patches, and they do make the fonts look great, but these were &lt;a href="http://www.infinality.net/forum/viewtopic.php?f=2&amp;amp;t=235"&gt;already merged&lt;/a&gt;.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="nx"&gt;rpmbuild&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;bb&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;freetype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;spec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;with&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;subpixel_rendering&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Even Cantarell font looks almost decent now.&lt;/p&gt;
&lt;p&gt;ARGH.&lt;/p&gt;</description><category>fedora</category><category>fonts</category><category>freetype</category><category>rendering</category><category>ubuntu</category><guid>https://www.keypressure.com/blog/subpixel-rendering-in-fedora-22/</guid><pubDate>Thu, 17 Sep 2015 06:16:14 GMT</pubDate></item><item><title>AppArmor config for Yandex.Disk</title><link>https://www.keypressure.com/blog/yandex-disk-apparmor/</link><dc:creator>Roman Yepishev</dc:creator><description>&lt;p&gt;I've been using &lt;a class="reference external" href="http://disk.yandex.ru"&gt;Yandex.Disk&lt;/a&gt; for quite a while for data synchronization and
file sharing because of its simplicity - a standard WebDAV implementation (+
extensions for file sharing, all &lt;a class="reference external" href="http://api.yandex.ru/disk/"&gt;documented&lt;/a&gt;, although in Russian) allowing for different clients to be used, a nice
web UI and they have introduced a Linux client recently which marries WebDAV
and XMPP which is used for OOB notifications.&lt;/p&gt;
&lt;p&gt;Being a bit cautious I decided to run it on my system but restrict access to
everything else, so I wrote the following &lt;a class="reference external" href="http://apparmor.net"&gt;apparmor&lt;/a&gt; config and now it is only
allowed to touch the files within ~/Yandex.Disk directory and it's
configuration, put it to &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;/etc/apparmor.d/usr.bin.yandex-disk&lt;/span&gt;&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.keypressure.com/listings/usr.bin.yandex-disk.html"&gt;usr.bin.yandex-disk&lt;/a&gt;  &lt;a class="reference external" href="https://www.keypressure.com/listings/usr.bin.yandex-disk"&gt;(Source)&lt;/a&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-1" name="rest_code_809946348a0048f68b7243725aac9fbf-1" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-1"&gt;&lt;/a&gt;# vim:syntax=apparmor
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-2" name="rest_code_809946348a0048f68b7243725aac9fbf-2" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-2"&gt;&lt;/a&gt;# Author: Roman Yepishev &amp;lt;roman.yepishev@yandex.com&amp;gt;
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-3" name="rest_code_809946348a0048f68b7243725aac9fbf-3" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-3"&gt;&lt;/a&gt;#include &amp;lt;tunables/global&amp;gt;
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-4" name="rest_code_809946348a0048f68b7243725aac9fbf-4" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-4"&gt;&lt;/a&gt;
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-5" name="rest_code_809946348a0048f68b7243725aac9fbf-5" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-5"&gt;&lt;/a&gt;/usr/bin/yandex-disk {
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-6" name="rest_code_809946348a0048f68b7243725aac9fbf-6" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-6"&gt;&lt;/a&gt;    #include &amp;lt;abstractions/base&amp;gt;
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-7" name="rest_code_809946348a0048f68b7243725aac9fbf-7" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-7"&gt;&lt;/a&gt;    #include &amp;lt;abstractions/nameservice&amp;gt;
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-8" name="rest_code_809946348a0048f68b7243725aac9fbf-8" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-8"&gt;&lt;/a&gt;    #include &amp;lt;abstractions/user-tmp&amp;gt;
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-9" name="rest_code_809946348a0048f68b7243725aac9fbf-9" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-9"&gt;&lt;/a&gt;    
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-10" name="rest_code_809946348a0048f68b7243725aac9fbf-10" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-10"&gt;&lt;/a&gt;    owner @{HOME}/.config/yandex-disk/ rw,
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-11" name="rest_code_809946348a0048f68b7243725aac9fbf-11" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-11"&gt;&lt;/a&gt;    owner @{HOME}/.config/yandex-disk/** rw,
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-12" name="rest_code_809946348a0048f68b7243725aac9fbf-12" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-12"&gt;&lt;/a&gt;
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-13" name="rest_code_809946348a0048f68b7243725aac9fbf-13" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-13"&gt;&lt;/a&gt;# yandex-disk can add itself to autostart configuration
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-14" name="rest_code_809946348a0048f68b7243725aac9fbf-14" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-14"&gt;&lt;/a&gt;    owner @{HOME}/.config/autostart/Yandex.Disk.desktop rw,
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-15" name="rest_code_809946348a0048f68b7243725aac9fbf-15" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-15"&gt;&lt;/a&gt;
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-16" name="rest_code_809946348a0048f68b7243725aac9fbf-16" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-16"&gt;&lt;/a&gt;# default sync location
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-17" name="rest_code_809946348a0048f68b7243725aac9fbf-17" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-17"&gt;&lt;/a&gt;    owner @{HOME}/Yandex.Disk/ rw,
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-18" name="rest_code_809946348a0048f68b7243725aac9fbf-18" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-18"&gt;&lt;/a&gt;    owner @{HOME}/Yandex.Disk/** rw,
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-19" name="rest_code_809946348a0048f68b7243725aac9fbf-19" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-19"&gt;&lt;/a&gt;
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-20" name="rest_code_809946348a0048f68b7243725aac9fbf-20" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-20"&gt;&lt;/a&gt;# or change the location like this:
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-21" name="rest_code_809946348a0048f68b7243725aac9fbf-21" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-21"&gt;&lt;/a&gt;#   owner @{HOME}/OtherFolder/ rw,
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-22" name="rest_code_809946348a0048f68b7243725aac9fbf-22" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-22"&gt;&lt;/a&gt;#   owner @{HOME}/OtherFolder/** rw,
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-23" name="rest_code_809946348a0048f68b7243725aac9fbf-23" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-23"&gt;&lt;/a&gt;
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-24" name="rest_code_809946348a0048f68b7243725aac9fbf-24" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-24"&gt;&lt;/a&gt;    /usr/bin/yandex-disk ixr,
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-25" name="rest_code_809946348a0048f68b7243725aac9fbf-25" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-25"&gt;&lt;/a&gt;
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-26" name="rest_code_809946348a0048f68b7243725aac9fbf-26" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-26"&gt;&lt;/a&gt;    /bin/dash ixr,
&lt;a id="rest_code_809946348a0048f68b7243725aac9fbf-27" name="rest_code_809946348a0048f68b7243725aac9fbf-27" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_809946348a0048f68b7243725aac9fbf-27"&gt;&lt;/a&gt;}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Yandex.Disk supports symlinks, so if symlinks to other locations are used,
these all should be described in the configuration file. Otherwise, the access
checks will fail and you will get this in kernel log:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_4bfbcee2032b455e9c12695af6dabae9-1" name="rest_code_4bfbcee2032b455e9c12695af6dabae9-1" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_4bfbcee2032b455e9c12695af6dabae9-1"&gt;&lt;/a&gt;[77109.846335] type=1400 audit(1386173505.778:116): apparmor="DENIED" ↩
&lt;a id="rest_code_4bfbcee2032b455e9c12695af6dabae9-2" name="rest_code_4bfbcee2032b455e9c12695af6dabae9-2" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_4bfbcee2032b455e9c12695af6dabae9-2"&gt;&lt;/a&gt;operation="open" parent=2000 profile="/usr/bin/yandex-disk" ↩
&lt;a id="rest_code_4bfbcee2032b455e9c12695af6dabae9-3" name="rest_code_4bfbcee2032b455e9c12695af6dabae9-3" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_4bfbcee2032b455e9c12695af6dabae9-3"&gt;&lt;/a&gt;name="/home/rye/_wine.tar.gz" pid=2869 comm="yandex-disk" ↩
&lt;a id="rest_code_4bfbcee2032b455e9c12695af6dabae9-4" name="rest_code_4bfbcee2032b455e9c12695af6dabae9-4" href="https://www.keypressure.com/blog/yandex-disk-apparmor/#rest_code_4bfbcee2032b455e9c12695af6dabae9-4"&gt;&lt;/a&gt;requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;P.S. Yeah, I've stopped using Ubuntu One for the time being.&lt;/p&gt;</description><category>apparmor</category><category>linux</category><category>ubuntu</category><category>yandex-disk</category><guid>https://www.keypressure.com/blog/yandex-disk-apparmor/</guid><pubDate>Wed, 04 Dec 2013 11:05:02 GMT</pubDate></item><item><title>Fixing Tizen SDK IDE Crash on Project Creation</title><link>https://www.keypressure.com/blog/tizen-sdk-ide-crash/</link><dc:creator>Roman Yepishev</dc:creator><description>&lt;p&gt;So recently I installed &lt;a class="reference external" href="https://www.tizen.org"&gt;Tizen SDK&lt;/a&gt; on my
Ubuntu 13.04 and found that I can't create a project - the java process
crashes in some native library and it was not obvious where.&lt;/p&gt;
&lt;p&gt;After some extensive googling I found a report about this particular problem -
&lt;a class="reference external" href="https://developer.tizen.org/forums/sdk-ide/tizen-2.0-magnolia-sdk-crashes-while-creating-new-project"&gt;TIZEN 2.0 MAGNOLIA SDK Crashes while creating a new project&lt;/a&gt; where
&lt;em&gt;daviderosa&lt;/em&gt; found the reason: Google Talk Plugin.&lt;/p&gt;
&lt;p&gt;Uninstalling the plugin allowed me to continue creating the project.&lt;/p&gt;
&lt;p&gt;Unfortunately the mozilla process launched by eclipse tries to load all the plugins possible automatically, and there is no switch to disable that. The
best solution would be to &lt;a class="reference external" href="http://www.eclipse.org/swt/faq.php#specifyprofile"&gt;specify Mozilla profile&lt;/a&gt; in your &lt;code class="docutils literal"&gt;eclipse.ini&lt;/code&gt;, but Tizen SDK 2.1 is based on a
SWT version which does not yet have this &lt;a class="reference external" href="http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=a59b6fabc99a8df2b83df5400ce5a7fa2acc24a3"&gt;feature&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Uninstalling google-talkplugin completely or moving the installed plugin links
(&lt;code class="docutils literal"&gt;/usr/lib/firefox/plugins&lt;/code&gt; and &lt;code class="docutils literal"&gt;/usr/lib/mozilla/plugins&lt;/code&gt;) and putting them back when needed seem
to be the solutions for now.&lt;/p&gt;</description><category>bugs</category><category>eclipse</category><category>fix</category><category>linux</category><category>ubuntu</category><guid>https://www.keypressure.com/blog/tizen-sdk-ide-crash/</guid><pubDate>Sat, 20 Jul 2013 19:19:13 GMT</pubDate></item><item><title>Bisecting Kernel Using PXE Boot</title><link>https://www.keypressure.com/blog/kernel-bisect-pxe/</link><dc:creator>Roman Yepishev</dc:creator><description>&lt;p&gt;Recently I found that an Atheros AR5BXB64 wireless card in my Acer Aspire One
AOA150 netbook stopped working properly in 13.04 with 3.8 kernel. The problem
was that any file download over the wireless interface had a high chance of
being corrupted. I was not able to download updates - every time something big
(like a kernel upgrade) got downloaded, I got the file, but the checksum did
not match. The card was able to inject copies of previous buffers into the
stream in a way that still passed IP and TCP checksum verification.&lt;/p&gt;
&lt;p&gt;This was exactly the same symptom we had when Active State Power Management
(ASPM) L0s was enabled for that PCI-E device, when the hardware itself was not
actually able to handle this state properly. It &lt;a class="reference external" href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/369005"&gt;was fixed&lt;/a&gt; in 2009 but
suddenly got broken in 3.8 again.&lt;/p&gt;
&lt;p&gt;I filed a bug (&lt;a class="reference external" href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1137513"&gt;LP:1137513&lt;/a&gt;) and, since I had a &lt;a class="reference external" href="http://wireless.kernel.org/en/users/Documentation/ASPM"&gt;workaround&lt;/a&gt;, I just
continued using the netbook with a &lt;code class="docutils literal"&gt;setpci&lt;/code&gt; call in &lt;code class="docutils literal"&gt;rc.local&lt;/code&gt; until I was
asked whether any prior Raring kernels exhibited this behavior.&lt;/p&gt;
&lt;p&gt;I booted 12.10 from a Flash drive and found that the card was working properly
there. Then I checked 3.7 kernels and found that the issue did not exist there
and appeared only in 3.8.0-rc1, which suggested there was indeed a regression
in the kernel. And the difference was that 3.7 and earlier kernels had
&lt;code class="docutils literal"&gt;LinkCtl: ASPM Disabled&lt;/code&gt; while 3.8+ had &lt;code class="docutils literal"&gt;LinkCtl: ASPM L0s L1 Enabled&lt;/code&gt; in the
&lt;code class="docutils literal"&gt;lspci &lt;span class="pre"&gt;-vv&lt;/span&gt;&lt;/code&gt; output.&lt;/p&gt;
&lt;p&gt;Since I was not able to find any relevant commits that looked like they were
deliberately doing something to ASPM handling, the only way to proceed was to
run a binary search. Since it was possible to check whether the bug was there
or not just by checking &lt;code class="docutils literal"&gt;lspci&lt;/code&gt;, it could and should have been automated.&lt;/p&gt;
&lt;p&gt;Bisect works by splitting the commits between known good and known bad revision
in half with every iteration and testing the commit in between. Rinse and
repeat until you hit a commit that made the switch from good to bad and that's
where the things broke.&lt;/p&gt;
&lt;p&gt;I had to test 5840 commits, with roughly 13 steps (2&lt;sup&gt;13&lt;/sup&gt;=8192, 2&lt;sup&gt;12&lt;/sup&gt;=4096). 13 manual reboots are 12 reboots too many so I went on to
set up an environment that would do everything for me. Additionally I did not
want to build the kernels on that netbook itself as it is pretty slow. The
build host and the netbook should have been separated if I wanted to finish the
task in a reasonable amount of time.&lt;/p&gt;
&lt;p&gt;So, here's the plan:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;Set up a PXE environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Find the minimal kernel config that exhibits the issue.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a custom initrd containing all the tools needed to detect whether an issue is there.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a script that can be reliably used by &lt;code class="docutils literal"&gt;git bisect&lt;/code&gt; to make it all run automatically.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- TEASER_END --&gt;
&lt;section id="pxe"&gt;
&lt;h2&gt;PXE&lt;/h2&gt;
&lt;p&gt;PXE is a &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Preboot_Execution_Environment"&gt;Pre-boot Execution Environment&lt;/a&gt; which allows
network boot without any local disk installation. It works by starting a DHCP
client early in the boot process, obtaining the address of the TFTP server that
hosts the boot images, downloading the image and passing the control over. TFTP
is a Trivial File Transfer Protocol, a really simple connection-less and
authentication-less protocol that's running over UDP.&lt;/p&gt;
&lt;p&gt;In my case I already had a DHCP server which was running on my OpenWRT-based
router. I set up a virtual machine and had my DHCP server direct the queries
for the boot images to that virtual machine. This was added to my
&lt;code class="docutils literal"&gt;/etc/dnsmasq.conf&lt;/code&gt; on the router:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_222054fb5e584afb836b1cadcf8d7542-1" name="rest_code_222054fb5e584afb836b1cadcf8d7542-1" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_222054fb5e584afb836b1cadcf8d7542-1"&gt;&lt;/a&gt;# PXE boot
&lt;a id="rest_code_222054fb5e584afb836b1cadcf8d7542-2" name="rest_code_222054fb5e584afb836b1cadcf8d7542-2" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_222054fb5e584afb836b1cadcf8d7542-2"&gt;&lt;/a&gt;dhcp-boot=pxelinux.0,raring-server-i386.lappyfamily.net,192.168.100.102
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then I switched to the "raring-server-i386" and installed &lt;code class="docutils literal"&gt;atftpd&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Ubuntu 12.04 Note&lt;/p&gt;
&lt;p&gt;The version in 12.04 suffers from &lt;a class="reference external" href="https://bugs.launchpad.net/ubuntu/+source/rlinetd/+bug/993101"&gt;a bug&lt;/a&gt; that prevents
&lt;code class="docutils literal"&gt;rlinetd&lt;/code&gt; from being set up properly. If you happen to hit the bug, you can
create the configuration manually by executing the following:&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_5d1d184b01be4478809486467d59f0a5-1" name="rest_code_5d1d184b01be4478809486467d59f0a5-1" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_5d1d184b01be4478809486467d59f0a5-1"&gt;&lt;/a&gt;. /etc/default/atftpd
&lt;a id="rest_code_5d1d184b01be4478809486467d59f0a5-2" name="rest_code_5d1d184b01be4478809486467d59f0a5-2" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_5d1d184b01be4478809486467d59f0a5-2"&gt;&lt;/a&gt;sudo update-inetd --group BOOT --add \
&lt;a id="rest_code_5d1d184b01be4478809486467d59f0a5-3" name="rest_code_5d1d184b01be4478809486467d59f0a5-3" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_5d1d184b01be4478809486467d59f0a5-3"&gt;&lt;/a&gt;"tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd $OPTIONS"
&lt;a id="rest_code_5d1d184b01be4478809486467d59f0a5-4" name="rest_code_5d1d184b01be4478809486467d59f0a5-4" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_5d1d184b01be4478809486467d59f0a5-4"&gt;&lt;/a&gt;unset OPTIONS
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In order to run Linux with PXE you will need to use &lt;a class="reference external" href="http://www.syslinux.org/wiki/index.php/PXELINUX"&gt;PXELINUX&lt;/a&gt;. The
required image, &lt;code class="docutils literal"&gt;pxelinux.0&lt;/code&gt; can be obtained after installing &lt;code class="docutils literal"&gt;syslinux&lt;/code&gt;
package from &lt;code class="docutils literal"&gt;/usr/lib/syslinux/pxelinux.0&lt;/code&gt;. By default &lt;code class="docutils literal"&gt;atftpd&lt;/code&gt; uses
&lt;code class="docutils literal"&gt;/srv/tftp&lt;/code&gt; as a root for the shared filesystem, so &lt;code class="docutils literal"&gt;pxelinux.0&lt;/code&gt; should go
to &lt;code class="docutils literal"&gt;/srv/tftp&lt;/code&gt; and be readable by &lt;code class="docutils literal"&gt;nobody&lt;/code&gt; user.&lt;/p&gt;
&lt;p&gt;Then I set up the netbook to boot from PXE. This will vary between different
BIOS setup interfaces, but it boils down to enabling integrated LAN adapter,
enabling boot ROM on that adapter and setting the network device as the first
one to boot from. A wired connection to an IPv4 network is needed.&lt;/p&gt;
&lt;p&gt;With &lt;code class="docutils literal"&gt;pxelinux.0&lt;/code&gt; in place I booted the netbook:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-1" name="rest_code_944f50dce0664450b6e542d0e60fc84e-1" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-1"&gt;&lt;/a&gt;Intel UNDI, PXE-2.1 (build 082)
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-2" name="rest_code_944f50dce0664450b6e542d0e60fc84e-2" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-2"&gt;&lt;/a&gt;Copyright (C) 1997-2000  Intel Corporation
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-3" name="rest_code_944f50dce0664450b6e542d0e60fc84e-3" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-4" name="rest_code_944f50dce0664450b6e542d0e60fc84e-4" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-4"&gt;&lt;/a&gt;This Product is covered by one or more of the following patents:
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-5" name="rest_code_944f50dce0664450b6e542d0e60fc84e-5" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-5"&gt;&lt;/a&gt;US5,307,459, US5,434,872, US5,732,094, US6,570,804, US6,115,776 and
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-6" name="rest_code_944f50dce0664450b6e542d0e60fc84e-6" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-6"&gt;&lt;/a&gt;US6,327,625
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-7" name="rest_code_944f50dce0664450b6e542d0e60fc84e-7" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-8" name="rest_code_944f50dce0664450b6e542d0e60fc84e-8" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-8"&gt;&lt;/a&gt;Realtek PCI Express Fast Ethernet Controller Series v1.15 (090224)
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-9" name="rest_code_944f50dce0664450b6e542d0e60fc84e-9" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-9"&gt;&lt;/a&gt;
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-10" name="rest_code_944f50dce0664450b6e542d0e60fc84e-10" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-10"&gt;&lt;/a&gt;CLIENT MAC ADDR: 00 1E 68 E2 10 AE  GUID: 40709CDA-A8E0-D411-8C6C-001E68E210AE
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-11" name="rest_code_944f50dce0664450b6e542d0e60fc84e-11" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-11"&gt;&lt;/a&gt;CLIENT IP: 192.168.1.14  MASK: 255.255.255.0  DHCP IP: 192.168.1.1
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-12" name="rest_code_944f50dce0664450b6e542d0e60fc84e-12" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-12"&gt;&lt;/a&gt;GATEWAY IP: 192.168.1.1
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-13" name="rest_code_944f50dce0664450b6e542d0e60fc84e-13" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-13"&gt;&lt;/a&gt;
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-14" name="rest_code_944f50dce0664450b6e542d0e60fc84e-14" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-14"&gt;&lt;/a&gt;
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-15" name="rest_code_944f50dce0664450b6e542d0e60fc84e-15" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-15"&gt;&lt;/a&gt;
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-16" name="rest_code_944f50dce0664450b6e542d0e60fc84e-16" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-16"&gt;&lt;/a&gt;!PXE entry point found (we hope) at 9D17:0109 via plan A
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-17" name="rest_code_944f50dce0664450b6e542d0e60fc84e-17" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-17"&gt;&lt;/a&gt;UNDI code segment at 9D17 len 19CA
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-18" name="rest_code_944f50dce0664450b6e542d0e60fc84e-18" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-18"&gt;&lt;/a&gt;UNDI data segment at 930A len A0D0
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-19" name="rest_code_944f50dce0664450b6e542d0e60fc84e-19" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-19"&gt;&lt;/a&gt;Getting cached packet  01 02 03
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-20" name="rest_code_944f50dce0664450b6e542d0e60fc84e-20" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-20"&gt;&lt;/a&gt;My IP address seems to be C0A8010E 192.168.1.14
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-21" name="rest_code_944f50dce0664450b6e542d0e60fc84e-21" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-21"&gt;&lt;/a&gt;ip=192.168.1.14:192.168.100.102:192.168.1.1:255.255.255.0
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-22" name="rest_code_944f50dce0664450b6e542d0e60fc84e-22" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-22"&gt;&lt;/a&gt;BOOTIF=01-00-1e-68-e2-10-ae
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-23" name="rest_code_944f50dce0664450b6e542d0e60fc84e-23" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-23"&gt;&lt;/a&gt;SYSUUID=40709cda-a8e0-d411-8c6c-001e68e210ae
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-24" name="rest_code_944f50dce0664450b6e542d0e60fc84e-24" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-24"&gt;&lt;/a&gt;TFTP prefix:
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-25" name="rest_code_944f50dce0664450b6e542d0e60fc84e-25" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-25"&gt;&lt;/a&gt;Unable to locate configuration file
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-26" name="rest_code_944f50dce0664450b6e542d0e60fc84e-26" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-26"&gt;&lt;/a&gt;
&lt;a id="rest_code_944f50dce0664450b6e542d0e60fc84e-27" name="rest_code_944f50dce0664450b6e542d0e60fc84e-27" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_944f50dce0664450b6e542d0e60fc84e-27"&gt;&lt;/a&gt;Boot failed: press a key to retry, or wait for reset...
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The line starting with "My IP address" is our &lt;code class="docutils literal"&gt;pxelinux.0&lt;/code&gt; working. Now we need
to put configuration and kernel in place.&lt;/p&gt;
&lt;p&gt;You can just grab the kernel and initrd from existing installation and put them
in &lt;code class="docutils literal"&gt;/srv/tftp&lt;/code&gt;. In my case I put kernel to &lt;code class="docutils literal"&gt;/srv/tftp/vmlinuz&lt;/code&gt; and initrd to
&lt;code class="docutils literal"&gt;/srv/tftp/initrd.img&lt;/code&gt;. If you check &lt;code class="docutils literal"&gt;/var/log/syslog&lt;/code&gt; on the TFTP server, you
will see that &lt;code class="docutils literal"&gt;pxelinux&lt;/code&gt; wanted to get the configuration from the following
locations:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_d6505b48b5b847eaa4e40af25a47d18c-1" name="rest_code_d6505b48b5b847eaa4e40af25a47d18c-1" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_d6505b48b5b847eaa4e40af25a47d18c-1"&gt;&lt;/a&gt;pxelinux.cfg/40709cda-a8e0-d411-8c6c-001e68e210ae
&lt;a id="rest_code_d6505b48b5b847eaa4e40af25a47d18c-2" name="rest_code_d6505b48b5b847eaa4e40af25a47d18c-2" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_d6505b48b5b847eaa4e40af25a47d18c-2"&gt;&lt;/a&gt;pxelinux.cfg/01-00-1e-68-e2-10-ae
&lt;a id="rest_code_d6505b48b5b847eaa4e40af25a47d18c-3" name="rest_code_d6505b48b5b847eaa4e40af25a47d18c-3" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_d6505b48b5b847eaa4e40af25a47d18c-3"&gt;&lt;/a&gt;pxelinux.cfg/C0A8010E
&lt;a id="rest_code_d6505b48b5b847eaa4e40af25a47d18c-4" name="rest_code_d6505b48b5b847eaa4e40af25a47d18c-4" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_d6505b48b5b847eaa4e40af25a47d18c-4"&gt;&lt;/a&gt;pxelinux.cfg/C0A8010
&lt;a id="rest_code_d6505b48b5b847eaa4e40af25a47d18c-5" name="rest_code_d6505b48b5b847eaa4e40af25a47d18c-5" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_d6505b48b5b847eaa4e40af25a47d18c-5"&gt;&lt;/a&gt;pxelinux.cfg/C0A801
&lt;a id="rest_code_d6505b48b5b847eaa4e40af25a47d18c-6" name="rest_code_d6505b48b5b847eaa4e40af25a47d18c-6" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_d6505b48b5b847eaa4e40af25a47d18c-6"&gt;&lt;/a&gt;pxelinux.cfg/C0A80
&lt;a id="rest_code_d6505b48b5b847eaa4e40af25a47d18c-7" name="rest_code_d6505b48b5b847eaa4e40af25a47d18c-7" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_d6505b48b5b847eaa4e40af25a47d18c-7"&gt;&lt;/a&gt;pxelinux.cfg/C0A8
&lt;a id="rest_code_d6505b48b5b847eaa4e40af25a47d18c-8" name="rest_code_d6505b48b5b847eaa4e40af25a47d18c-8" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_d6505b48b5b847eaa4e40af25a47d18c-8"&gt;&lt;/a&gt;pxelinux.cfg/C0A
&lt;a id="rest_code_d6505b48b5b847eaa4e40af25a47d18c-9" name="rest_code_d6505b48b5b847eaa4e40af25a47d18c-9" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_d6505b48b5b847eaa4e40af25a47d18c-9"&gt;&lt;/a&gt;pxelinux.cfg/C0
&lt;a id="rest_code_d6505b48b5b847eaa4e40af25a47d18c-10" name="rest_code_d6505b48b5b847eaa4e40af25a47d18c-10" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_d6505b48b5b847eaa4e40af25a47d18c-10"&gt;&lt;/a&gt;pxelinux.cfg/C
&lt;a id="rest_code_d6505b48b5b847eaa4e40af25a47d18c-11" name="rest_code_d6505b48b5b847eaa4e40af25a47d18c-11" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_d6505b48b5b847eaa4e40af25a47d18c-11"&gt;&lt;/a&gt;pxelinux.cfg/default
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you are wondering, C0A8010E is 192.168.1.14 in hexadecimal notation.&lt;/p&gt;
&lt;p&gt;So we need to put configuration at some location it is querying. I decided to
use the MAC address, &lt;code class="docutils literal"&gt;01:00:1e:68:e2:10:ae&lt;/code&gt; and put the following configuration
to &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;/srv/tftp/pxelinux.cfg/01-00-1e-68-e2-10-ae&lt;/span&gt;&lt;/code&gt; (yes, the folder &lt;em&gt;is&lt;/em&gt; named
&lt;code class="docutils literal"&gt;pxelinux.cfg&lt;/code&gt;):&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_ba18779a9e924c408c03302293bff33d-1" name="rest_code_ba18779a9e924c408c03302293bff33d-1" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_ba18779a9e924c408c03302293bff33d-1"&gt;&lt;/a&gt;DEFAULT linux
&lt;a id="rest_code_ba18779a9e924c408c03302293bff33d-2" name="rest_code_ba18779a9e924c408c03302293bff33d-2" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_ba18779a9e924c408c03302293bff33d-2"&gt;&lt;/a&gt;LABEL linux
&lt;a id="rest_code_ba18779a9e924c408c03302293bff33d-3" name="rest_code_ba18779a9e924c408c03302293bff33d-3" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_ba18779a9e924c408c03302293bff33d-3"&gt;&lt;/a&gt;KERNEL vmlinuz
&lt;a id="rest_code_ba18779a9e924c408c03302293bff33d-4" name="rest_code_ba18779a9e924c408c03302293bff33d-4" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_ba18779a9e924c408c03302293bff33d-4"&gt;&lt;/a&gt;APPEND initrd=initrd.img panic=10
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can reboot your device now and you will see that the kernel is loaded,
&lt;code class="docutils literal"&gt;initrd.img&lt;/code&gt; is loaded too but the boot breaks since the root device is
undefined. While you can put the root information from your grub configuration,
we don't actually need to do that. As we are going to build our own kernel with
minimal number of features, we will run everything from the intitial RAM drive,
initrd. I put the &lt;code class="docutils literal"&gt;panic=10&lt;/code&gt; option so that the kernel reboots after 10 seconds
in case it fails so that I would not need to shut the netbook down manually.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="kernel"&gt;
&lt;h2&gt;Kernel&lt;/h2&gt;
&lt;p&gt;Well, that was easy. I grabbed the git repository of Linus,
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git&lt;/span&gt;&lt;/code&gt;, checked out
v3.8-rc1 and ran &lt;code class="docutils literal"&gt;make menuconfig&lt;/code&gt;&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="/galleries/dropbox/make-menuconfig.png" src="https://www.keypressure.com/galleries/dropbox/make-menuconfig.png"&gt;
&lt;/figure&gt;
&lt;p&gt;Since I was interested in ath5k module only I disabled loadable module support
and made ath5k a built-in module. I left quite a few features I did not
know/care about enabled which I believe has somehow increased the build time,
but in the end it took 3 minutes to build a kernel on my VM with 4 concurrent
builds (&lt;code class="docutils literal"&gt;make &lt;span class="pre"&gt;-j&lt;/span&gt; 4&lt;/code&gt;, the VM had 4 CPUs allocated)&lt;/p&gt;
&lt;/section&gt;
&lt;section id="initrd"&gt;
&lt;h2&gt;initrd&lt;/h2&gt;
&lt;p&gt;When kernel boots with initrd, it mounts that image as a root device and runs
&lt;code class="docutils literal"&gt;init&lt;/code&gt; as PID 1 trying &lt;code class="docutils literal"&gt;/sbin/init&lt;/code&gt;, &lt;code class="docutils literal"&gt;/etc/init&lt;/code&gt;, &lt;code class="docutils literal"&gt;/bin/init&lt;/code&gt; and &lt;code class="docutils literal"&gt;/bin/sh&lt;/code&gt;. In
case &lt;code class="docutils literal"&gt;/bin/sh&lt;/code&gt; is handled by &lt;code class="docutils literal"&gt;busybox&lt;/code&gt; and it is running as PID 1, it attempts
to run &lt;code class="docutils literal"&gt;/init&lt;/code&gt; and &lt;code class="docutils literal"&gt;/sbin/init&lt;/code&gt;. So I needed to create a new initramfs that had
everything inside the /init script itself:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;Setting up /dev, /proc, /sys and /tmp in case I need that for debugging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configure the network interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Execute the required test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wait for a reboot command.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here's what I came up with, the first part is stolen from /init that ships with Ubuntu:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-1" name="rest_code_dcac33192c0a48f886129c096675e16b-1" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-1"&gt;&lt;/a&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-2" name="rest_code_dcac33192c0a48f886129c096675e16b-2" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-2"&gt;&lt;/a&gt;
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-3" name="rest_code_dcac33192c0a48f886129c096675e16b-3" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-3"&gt;&lt;/a&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-d&lt;span class="w"&gt; &lt;/span&gt;/dev&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;mkdir&lt;span class="w"&gt; &lt;/span&gt;-m&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0755&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;/dev
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-4" name="rest_code_dcac33192c0a48f886129c096675e16b-4" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-4"&gt;&lt;/a&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-d&lt;span class="w"&gt; &lt;/span&gt;/root&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;mkdir&lt;span class="w"&gt; &lt;/span&gt;-m&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0700&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;/root
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-5" name="rest_code_dcac33192c0a48f886129c096675e16b-5" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-5"&gt;&lt;/a&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-d&lt;span class="w"&gt; &lt;/span&gt;/sys&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;mkdir&lt;span class="w"&gt; &lt;/span&gt;/sys
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-6" name="rest_code_dcac33192c0a48f886129c096675e16b-6" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-6"&gt;&lt;/a&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-d&lt;span class="w"&gt; &lt;/span&gt;/proc&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;mkdir&lt;span class="w"&gt; &lt;/span&gt;/proc
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-7" name="rest_code_dcac33192c0a48f886129c096675e16b-7" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-7"&gt;&lt;/a&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-d&lt;span class="w"&gt; &lt;/span&gt;/tmp&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;mkdir&lt;span class="w"&gt; &lt;/span&gt;/tmp
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-8" name="rest_code_dcac33192c0a48f886129c096675e16b-8" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-8"&gt;&lt;/a&gt;mkdir&lt;span class="w"&gt; &lt;/span&gt;-p&lt;span class="w"&gt; &lt;/span&gt;/var/lock
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-9" name="rest_code_dcac33192c0a48f886129c096675e16b-9" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-9"&gt;&lt;/a&gt;mount&lt;span class="w"&gt; &lt;/span&gt;-t&lt;span class="w"&gt; &lt;/span&gt;sysfs&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;nodev,noexec,nosuid&lt;span class="w"&gt; &lt;/span&gt;sysfs&lt;span class="w"&gt; &lt;/span&gt;/sys
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-10" name="rest_code_dcac33192c0a48f886129c096675e16b-10" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-10"&gt;&lt;/a&gt;mount&lt;span class="w"&gt; &lt;/span&gt;-t&lt;span class="w"&gt; &lt;/span&gt;proc&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;nodev,noexec,nosuid&lt;span class="w"&gt; &lt;/span&gt;proc&lt;span class="w"&gt; &lt;/span&gt;/proc
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-11" name="rest_code_dcac33192c0a48f886129c096675e16b-11" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-11"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# Some things don't work properly without /etc/mtab.&lt;/span&gt;
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-12" name="rest_code_dcac33192c0a48f886129c096675e16b-12" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-12"&gt;&lt;/a&gt;ln&lt;span class="w"&gt; &lt;/span&gt;-sf&lt;span class="w"&gt; &lt;/span&gt;/proc/mounts&lt;span class="w"&gt; &lt;/span&gt;/etc/mtab
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-13" name="rest_code_dcac33192c0a48f886129c096675e16b-13" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-13"&gt;&lt;/a&gt;
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-14" name="rest_code_dcac33192c0a48f886129c096675e16b-14" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-14"&gt;&lt;/a&gt;ifconfig&lt;span class="w"&gt; &lt;/span&gt;eth0&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;192&lt;/span&gt;.168.1.14
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-15" name="rest_code_dcac33192c0a48f886129c096675e16b-15" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-15"&gt;&lt;/a&gt;route&lt;span class="w"&gt; &lt;/span&gt;add&lt;span class="w"&gt; &lt;/span&gt;default&lt;span class="w"&gt; &lt;/span&gt;gw&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;192&lt;/span&gt;.168.1.1
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-16" name="rest_code_dcac33192c0a48f886129c096675e16b-16" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-16"&gt;&lt;/a&gt;
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-17" name="rest_code_dcac33192c0a48f886129c096675e16b-17" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-17"&gt;&lt;/a&gt;sleep&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-18" name="rest_code_dcac33192c0a48f886129c096675e16b-18" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-18"&gt;&lt;/a&gt;
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-19" name="rest_code_dcac33192c0a48f886129c096675e16b-19" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-19"&gt;&lt;/a&gt;lspci&lt;span class="w"&gt; &lt;/span&gt;-vv&lt;span class="w"&gt; &lt;/span&gt;-d&lt;span class="w"&gt; &lt;/span&gt;168c:001c&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;nc&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;192&lt;/span&gt;.168.100.102&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;5555&lt;/span&gt;
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-20" name="rest_code_dcac33192c0a48f886129c096675e16b-20" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-20"&gt;&lt;/a&gt;
&lt;a id="rest_code_dcac33192c0a48f886129c096675e16b-21" name="rest_code_dcac33192c0a48f886129c096675e16b-21" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_dcac33192c0a48f886129c096675e16b-21"&gt;&lt;/a&gt;nc&lt;span class="w"&gt; &lt;/span&gt;-l&lt;span class="w"&gt; &lt;/span&gt;-p&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;5555&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;reboot&lt;span class="w"&gt; &lt;/span&gt;-f
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So this init script configures the wired interface, sends the output of &lt;code class="docutils literal"&gt;lspci&lt;/code&gt;
to the host running the bisect script and listens to an incoming TCP connection
on port 5555 so that it would reboot the host when connection is terminated.
There is no need for anything fancier.&lt;/p&gt;
&lt;p&gt;The initramfs contained the minimal set of applications and libraries, but you
will want to grab &lt;code class="docutils literal"&gt;busybox&lt;/code&gt; from a working system as it has a &lt;code class="docutils literal"&gt;reboot&lt;/code&gt; applet
which is missing from the version shipped with initrd by default on Ubuntu
systems. I needed to do a bit of tweaking before I got everything working as I
wanted so I had /bin/sh (symlink to /bin/busybox) originally in place of all
these &lt;code class="docutils literal"&gt;lspci&lt;/code&gt; calls. Also I used &lt;code class="docutils literal"&gt;nc&lt;/code&gt; from &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;netcat-traditional&lt;/span&gt;&lt;/code&gt; since it had
less dependencies.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-1" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-1" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-1"&gt;&lt;/a&gt;ubuntu@raring-server-i386:~/minroot$ find
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-2" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-2" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-2"&gt;&lt;/a&gt;./init
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-3" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-3" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-3"&gt;&lt;/a&gt;./bin
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-4" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-4" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-4"&gt;&lt;/a&gt;./bin/sh
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-5" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-5" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-5"&gt;&lt;/a&gt;./bin/lspci
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-6" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-6" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-6"&gt;&lt;/a&gt;./bin/nc
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-7" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-7" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-7"&gt;&lt;/a&gt;./bin/bash
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-8" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-8" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-8"&gt;&lt;/a&gt;./bin/busybox
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-9" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-9" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-9"&gt;&lt;/a&gt;./lib
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-10" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-10" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-10"&gt;&lt;/a&gt;./lib/ld-linux.so.2
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-11" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-11" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-11"&gt;&lt;/a&gt;./lib/libresolv.so.2
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-12" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-12" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-12"&gt;&lt;/a&gt;./lib/libc.so.6
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-13" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-13" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-13"&gt;&lt;/a&gt;./lib/libz.so.1
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-14" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-14" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-14"&gt;&lt;/a&gt;./lib/libpci.so.3
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-15" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-15" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-15"&gt;&lt;/a&gt;./dev
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-16" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-16" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-16"&gt;&lt;/a&gt;./dev/ram0
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-17" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-17" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-17"&gt;&lt;/a&gt;./dev/console
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-18" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-18" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-18"&gt;&lt;/a&gt;./dev/null
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-19" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-19" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-19"&gt;&lt;/a&gt;ubuntu@raring-server-i386:~/minroot$ find | cpio --format=newc -o | gzip &amp;gt; /srv/tftp/initrd.img
&lt;a id="rest_code_4fac5222791b4ad8ab2431ae154499c3-20" name="rest_code_4fac5222791b4ad8ab2431ae154499c3-20" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_4fac5222791b4ad8ab2431ae154499c3-20"&gt;&lt;/a&gt;7806 blocks
&lt;/pre&gt;&lt;/div&gt;
&lt;/section&gt;
&lt;section id="bisect-script"&gt;
&lt;h2&gt;Bisect script&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.kernel.org/pub/software/scm/git/docs/git-bisect.html"&gt;git-bisect run&lt;/a&gt; expects the script to return 0 when this build is considered
a success or 1 when the build is considered a failure, so in our case a
successful build will have "ASPM Disabled" in the output. &lt;code class="docutils literal"&gt;grep&lt;/code&gt; returns 0 when
a string is found, 1 when not found and 2 when error, so we can just use that.&lt;/p&gt;
&lt;p&gt;I called the script 'bisect-helper' and put it in my home directory on the VM.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-1" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-1" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-1"&gt;&lt;/a&gt;&lt;span class="ch"&gt;#!/bin/bash&lt;/span&gt;
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-2" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-2" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-2"&gt;&lt;/a&gt;
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-3" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-3" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-3"&gt;&lt;/a&gt;cp&lt;span class="w"&gt; &lt;/span&gt;~/kernel.config&lt;span class="w"&gt; &lt;/span&gt;~/linux/.config
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-4" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-4" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-4"&gt;&lt;/a&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;~/linux
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-5" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-5" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-5"&gt;&lt;/a&gt;make&lt;span class="w"&gt; &lt;/span&gt;olddefconfig
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-6" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-6" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-6"&gt;&lt;/a&gt;make&lt;span class="w"&gt; &lt;/span&gt;clean
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-7" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-7" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-7"&gt;&lt;/a&gt;make&lt;span class="w"&gt; &lt;/span&gt;-j&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-8" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-8" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-8"&gt;&lt;/a&gt;cp&lt;span class="w"&gt; &lt;/span&gt;arch/i386/boot/bzImage&lt;span class="w"&gt; &lt;/span&gt;/srv/tftp/vmlinuz
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-9" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-9" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-9"&gt;&lt;/a&gt;
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-10" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-10" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-10"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# reboot netbook&lt;/span&gt;
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-11" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-11" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-11"&gt;&lt;/a&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"reboot"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;nc&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;192&lt;/span&gt;.168.1.14&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;5555&lt;/span&gt;
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-12" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-12" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-12"&gt;&lt;/a&gt;
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-13" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-13" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-13"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# when it goes up, it will send us a message&lt;/span&gt;
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-14" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-14" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-14"&gt;&lt;/a&gt;nc&lt;span class="w"&gt; &lt;/span&gt;-l&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;5555&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;grep&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'LnkCtl:\s*ASPM Disabled'&lt;/span&gt;
&lt;a id="rest_code_f5e088feb4e749e39a2da12669cb47f7-15" name="rest_code_f5e088feb4e749e39a2da12669cb47f7-15" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_f5e088feb4e749e39a2da12669cb47f7-15"&gt;&lt;/a&gt;&lt;span class="nb"&gt;exit&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The script needs to be tested manually first to check whether it is actually
producing the results expected:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-1" name="rest_code_0f147678e24845aa84dd0de635c6009e-1" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-1"&gt;&lt;/a&gt;ubuntu@raring-server-i386:~/linux$ git checkout v3.7
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-2" name="rest_code_0f147678e24845aa84dd0de635c6009e-2" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-2"&gt;&lt;/a&gt;Checking out files: 100% (11706/11706), done.
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-3" name="rest_code_0f147678e24845aa84dd0de635c6009e-3" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-3"&gt;&lt;/a&gt;Previous HEAD position was 19f949f... Linux 3.8
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-4" name="rest_code_0f147678e24845aa84dd0de635c6009e-4" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-4"&gt;&lt;/a&gt;HEAD is now at 2959440... Linux 3.7
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-5" name="rest_code_0f147678e24845aa84dd0de635c6009e-5" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-5"&gt;&lt;/a&gt;ubuntu@raring-server-i386:~/linux$ ~/bisect-helper; echo $?
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-6" name="rest_code_0f147678e24845aa84dd0de635c6009e-6" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-6"&gt;&lt;/a&gt;...
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-7" name="rest_code_0f147678e24845aa84dd0de635c6009e-7" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-7"&gt;&lt;/a&gt;Kernel: arch/x86/boot/bzImage is ready  (#40)
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-8" name="rest_code_0f147678e24845aa84dd0de635c6009e-8" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-8"&gt;&lt;/a&gt;        LnkCtl: ASPM Disabled; RCB 128 bytes Disabled- Retrain- CommClk+
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-9" name="rest_code_0f147678e24845aa84dd0de635c6009e-9" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-9"&gt;&lt;/a&gt;0
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-10" name="rest_code_0f147678e24845aa84dd0de635c6009e-10" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-10"&gt;&lt;/a&gt;ubuntu@raring-server-i386:~/linux$ git checkout v3.8
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-11" name="rest_code_0f147678e24845aa84dd0de635c6009e-11" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-11"&gt;&lt;/a&gt;Checking out files: 100% (11706/11706), done.
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-12" name="rest_code_0f147678e24845aa84dd0de635c6009e-12" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-12"&gt;&lt;/a&gt;Previous HEAD position was 2959440... Linux 3.7
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-13" name="rest_code_0f147678e24845aa84dd0de635c6009e-13" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-13"&gt;&lt;/a&gt;HEAD is now at 19f949f... Linux 3.8
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-14" name="rest_code_0f147678e24845aa84dd0de635c6009e-14" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-14"&gt;&lt;/a&gt;ubuntu@raring-server-i386:~/linux$ ~/bisect-helper; echo $?
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-15" name="rest_code_0f147678e24845aa84dd0de635c6009e-15" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-15"&gt;&lt;/a&gt;...
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-16" name="rest_code_0f147678e24845aa84dd0de635c6009e-16" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-16"&gt;&lt;/a&gt;Kernel: arch/x86/boot/bzImage is ready  (#41)
&lt;a id="rest_code_0f147678e24845aa84dd0de635c6009e-17" name="rest_code_0f147678e24845aa84dd0de635c6009e-17" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_0f147678e24845aa84dd0de635c6009e-17"&gt;&lt;/a&gt;1
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Yep, looks like it is working. Now let the madness begin!&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-1" name="rest_code_497d3a086dd6480bb0391383644139fe-1" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-1"&gt;&lt;/a&gt;ubuntu@raring-server-i386:~/linux$ git bisect start v3.8-rc1 v3.7
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-2" name="rest_code_497d3a086dd6480bb0391383644139fe-2" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-2"&gt;&lt;/a&gt;Bisecting: 5840 revisions left to test after this (roughly 13 steps)
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-3" name="rest_code_497d3a086dd6480bb0391383644139fe-3" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-3"&gt;&lt;/a&gt;[6be35c700f742e911ecedd07fcc43d4439922334] Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-4" name="rest_code_497d3a086dd6480bb0391383644139fe-4" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-4"&gt;&lt;/a&gt;ubuntu@raring-server-i386:~/linux$ time git bisect run ../bisect-helper
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-5" name="rest_code_497d3a086dd6480bb0391383644139fe-5" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-5"&gt;&lt;/a&gt;running ../bisect-helper
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-6" name="rest_code_497d3a086dd6480bb0391383644139fe-6" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-6"&gt;&lt;/a&gt;...
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-7" name="rest_code_497d3a086dd6480bb0391383644139fe-7" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-7"&gt;&lt;/a&gt;(an hour later)
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-8" name="rest_code_497d3a086dd6480bb0391383644139fe-8" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-8"&gt;&lt;/a&gt;...
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-9" name="rest_code_497d3a086dd6480bb0391383644139fe-9" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-9"&gt;&lt;/a&gt;8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6 is the first bad commit
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-10" name="rest_code_497d3a086dd6480bb0391383644139fe-10" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-10"&gt;&lt;/a&gt;commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-11" name="rest_code_497d3a086dd6480bb0391383644139fe-11" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-11"&gt;&lt;/a&gt;Author: Taku Izumi &amp;lt;izumi.taku@jp.fujitsu.com&amp;gt;
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-12" name="rest_code_497d3a086dd6480bb0391383644139fe-12" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-12"&gt;&lt;/a&gt;Date:   Tue Oct 30 15:27:13 2012 +0900
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-13" name="rest_code_497d3a086dd6480bb0391383644139fe-13" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-13"&gt;&lt;/a&gt;
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-14" name="rest_code_497d3a086dd6480bb0391383644139fe-14" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-14"&gt;&lt;/a&gt;    PCI/ACPI: Request _OSC control before scanning PCI root bus
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-15" name="rest_code_497d3a086dd6480bb0391383644139fe-15" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-15"&gt;&lt;/a&gt;
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-16" name="rest_code_497d3a086dd6480bb0391383644139fe-16" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-16"&gt;&lt;/a&gt;    This patch moves up the code block to request _OSC control in order to
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-17" name="rest_code_497d3a086dd6480bb0391383644139fe-17" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-17"&gt;&lt;/a&gt;    separate ACPI work and PCI work in acpi_pci_root_add().
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-18" name="rest_code_497d3a086dd6480bb0391383644139fe-18" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-18"&gt;&lt;/a&gt;
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-19" name="rest_code_497d3a086dd6480bb0391383644139fe-19" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-19"&gt;&lt;/a&gt;    Signed-off-by: Taku Izumi &amp;lt;izumi.taku@jp.fujitsu.com&amp;gt;
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-20" name="rest_code_497d3a086dd6480bb0391383644139fe-20" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-20"&gt;&lt;/a&gt;    Signed-off-by: Bjorn Helgaas &amp;lt;bhelgaas@google.com&amp;gt;
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-21" name="rest_code_497d3a086dd6480bb0391383644139fe-21" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-21"&gt;&lt;/a&gt;
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-22" name="rest_code_497d3a086dd6480bb0391383644139fe-22" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-22"&gt;&lt;/a&gt;:040000 040000 ac58db59f5eaf541d5cb36197aaaf5dfe319ea37 d25e645d59da508e3a1bcb01509cbfb5c7a8239b M  drivers
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-23" name="rest_code_497d3a086dd6480bb0391383644139fe-23" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-23"&gt;&lt;/a&gt;bisect run success
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-24" name="rest_code_497d3a086dd6480bb0391383644139fe-24" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-24"&gt;&lt;/a&gt;
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-25" name="rest_code_497d3a086dd6480bb0391383644139fe-25" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-25"&gt;&lt;/a&gt;real    63m39.674s
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-26" name="rest_code_497d3a086dd6480bb0391383644139fe-26" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-26"&gt;&lt;/a&gt;user    155m30.732s
&lt;a id="rest_code_497d3a086dd6480bb0391383644139fe-27" name="rest_code_497d3a086dd6480bb0391383644139fe-27" href="https://www.keypressure.com/blog/kernel-bisect-pxe/#rest_code_497d3a086dd6480bb0391383644139fe-27"&gt;&lt;/a&gt;sys 27m33.772s
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It took ~64 minutes to run 13 kernel builds and the offending commit was
discovered. I filed a &lt;a class="reference external" href="https://bugzilla.kernel.org/show_bug.cgi?id=55211"&gt;bug&lt;/a&gt;, it got picked up by
Yinghai Lu, who found that this commit triggered an issue in another function
that differentiated between ASPM handling for non-hotplug and hotplug cases.
This was affecting iwlwifi as well as other modules which were using
&lt;code class="docutils literal"&gt;pci_disable_link_state&lt;/code&gt; call, so it was a real issue.&lt;/p&gt;
&lt;p&gt;Yinghai Lu has posted the patch to the kernel-pci mailing list and it should be
merged at some point.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="summary"&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;p&gt;I've always wanted to do git bisect on something, but I had no idea what to
start with. Bisecting is not specific to git, there's a
&lt;a class="reference external" href="http://doc.bazaar.canonical.com/plugins/en/bisect-plugin.html"&gt;Bazaar plugin&lt;/a&gt;
as well and it is fairly easy to use this technique with any other VCS.&lt;/p&gt;
&lt;p&gt;Minimizing the kernel build time is important. Originally I spent nearly 2
hours fiddling with the kernel configuration until I removed most of the things
that were completely irrelevant to the issue being debugged. Having a powerful
machine to build the software is a must in case the actual test needs to be
performed on a slower machine.&lt;/p&gt;
&lt;p&gt;Booting linux with PXE involves quite a few moving parts (DHCP, TFTP, boot
image, kernel and initrd) that may take a while to configure, but all the time
invested in this configuration will eventually pay off.&lt;/p&gt;
&lt;/section&gt;</description><category>bisect</category><category>bugs</category><category>git</category><category>kernel</category><category>linux</category><category>pxe</category><category>raring</category><category>the-hard-way</category><category>ubuntu</category><category>ubuntu planet</category><category>wifi</category><guid>https://www.keypressure.com/blog/kernel-bisect-pxe/</guid><pubDate>Tue, 19 Mar 2013 15:01:50 GMT</pubDate></item><item><title>Getting rid of bash annoyances</title><link>https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/</link><dc:creator>Roman Yepishev</dc:creator><description>&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_9b36173b2c04465088f10dc458692dce-1" name="rest_code_9b36173b2c04465088f10dc458692dce-1" href="https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/#rest_code_9b36173b2c04465088f10dc458692dce-1"&gt;&lt;/a&gt;$ zcat /boot/initrd.&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;&amp;lt;TAB!&amp;gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I know the file is there and I know it’s a file an application can handle, but
bash autocompletion tries to be smart by refusing to provide the file name.&lt;/p&gt;
&lt;p&gt;This gets really annoying if you happen to work with files that don’t have an
extension the autocompletion scripts expect or you are running a command using
sudo and want to pass the filename.&lt;/p&gt;
&lt;p&gt;There is a dedicated shortcut for filename completion – &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;M-/&lt;/span&gt;&lt;/code&gt; by default, but
I’ve never used tab completion for options and that means that I can get rid
of it.&lt;/p&gt;
&lt;p&gt;There is no need to uninstall anything, &lt;a class="reference external" href="http://blog.onetechnical.com/2012/06/19/disable-bash-autocompletion-on-ubunt/"&gt;adding&lt;/a&gt; complete -r to &lt;code class="docutils literal"&gt;.bashrc&lt;/code&gt; will
remove all the completion functions.&lt;/p&gt;
&lt;p&gt;To completely disable programmatic completion, add &lt;code class="docutils literal"&gt;shopt &lt;span class="pre"&gt;-u&lt;/span&gt; progcomp&lt;/code&gt; to
&lt;code class="docutils literal"&gt;.bashrc&lt;/code&gt;.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_5a5ccd535fce426bbe59f3a31bdd02a3-1" name="rest_code_5a5ccd535fce426bbe59f3a31bdd02a3-1" href="https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/#rest_code_5a5ccd535fce426bbe59f3a31bdd02a3-1"&gt;&lt;/a&gt;$ zcat /boot/initrd.img-3.&amp;lt;tab&amp;gt;
&lt;a id="rest_code_5a5ccd535fce426bbe59f3a31bdd02a3-2" name="rest_code_5a5ccd535fce426bbe59f3a31bdd02a3-2" href="https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/#rest_code_5a5ccd535fce426bbe59f3a31bdd02a3-2"&gt;&lt;/a&gt;initrd.img-3.2.0-29-generic         initrd.img-3.7.0-7-generic
&lt;a id="rest_code_5a5ccd535fce426bbe59f3a31bdd02a3-3" name="rest_code_5a5ccd535fce426bbe59f3a31bdd02a3-3" href="https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/#rest_code_5a5ccd535fce426bbe59f3a31bdd02a3-3"&gt;&lt;/a&gt;initrd.img-3.2.0-35-generic         initrd.img-3.8.0-030800rc2-generic
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Nice.&lt;/p&gt;
&lt;p&gt;Another thing that was annoying me for a while is &lt;a class="reference external" href="https://launchpad.net/command-not-found"&gt;command-not-found&lt;/a&gt; package.
It is extremely helpful at discovering what package the application I want is
in. However, there were quite a few times when I made a typo, pressed Enter,
noticed it right away but had to wait for a second or so before I got the
“command not found” and the prompt back. When disk is really busy, making a
typo costs me another 30 seconds of disk trashing before &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;command-not-found&lt;/span&gt;&lt;/code&gt;
comes up with a friendly suggestion that &lt;code class="docutils literal"&gt;killal&lt;/code&gt; is better spelled as &lt;code class="docutils literal"&gt;Command
'killall' from package 'psmisc'&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Having &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;command-not-found&lt;/span&gt;&lt;/code&gt; installed and available but not kicking in on every
occasion is preferred. The function bash runs in case it can’t find the
command is &lt;code class="docutils literal"&gt;command_not_found_handle&lt;/code&gt; so we simply need to unset this function
in &lt;code class="docutils literal"&gt;.bashrc&lt;/code&gt; and add an &lt;code class="docutils literal"&gt;alias&lt;/code&gt; (in my case &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;packages-providing&lt;/span&gt;&lt;/code&gt; after &lt;a class="reference external" href="https://bugs.launchpad.net/command-not-found/+bug/486716"&gt;LP:486716&lt;/a&gt;,
but it can be anything) which will execute the real command-not-found script:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_1902ad311b5c40b8bb044b4a6f2a7353-1" name="rest_code_1902ad311b5c40b8bb044b4a6f2a7353-1" href="https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/#rest_code_1902ad311b5c40b8bb044b4a6f2a7353-1"&gt;&lt;/a&gt;unset command_not_found_handle
&lt;a id="rest_code_1902ad311b5c40b8bb044b4a6f2a7353-2" name="rest_code_1902ad311b5c40b8bb044b4a6f2a7353-2" href="https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/#rest_code_1902ad311b5c40b8bb044b4a6f2a7353-2"&gt;&lt;/a&gt;alias packages-providing='/usr/lib/command-not-found --no-failure-msg'
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So now I will be given the package name only when I want it:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_1d64de7924334a3fa46d16150c5e6189-1" name="rest_code_1d64de7924334a3fa46d16150c5e6189-1" href="https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/#rest_code_1d64de7924334a3fa46d16150c5e6189-1"&gt;&lt;/a&gt;$ sl
&lt;a id="rest_code_1d64de7924334a3fa46d16150c5e6189-2" name="rest_code_1d64de7924334a3fa46d16150c5e6189-2" href="https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/#rest_code_1d64de7924334a3fa46d16150c5e6189-2"&gt;&lt;/a&gt;bash: sl: command not found
&lt;a id="rest_code_1d64de7924334a3fa46d16150c5e6189-3" name="rest_code_1d64de7924334a3fa46d16150c5e6189-3" href="https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/#rest_code_1d64de7924334a3fa46d16150c5e6189-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_1d64de7924334a3fa46d16150c5e6189-4" name="rest_code_1d64de7924334a3fa46d16150c5e6189-4" href="https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/#rest_code_1d64de7924334a3fa46d16150c5e6189-4"&gt;&lt;/a&gt;$ packages-providing sl
&lt;a id="rest_code_1d64de7924334a3fa46d16150c5e6189-5" name="rest_code_1d64de7924334a3fa46d16150c5e6189-5" href="https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/#rest_code_1d64de7924334a3fa46d16150c5e6189-5"&gt;&lt;/a&gt;The program 'sl' is currently not installed. You can install it by typing:
&lt;a id="rest_code_1d64de7924334a3fa46d16150c5e6189-6" name="rest_code_1d64de7924334a3fa46d16150c5e6189-6" href="https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/#rest_code_1d64de7924334a3fa46d16150c5e6189-6"&gt;&lt;/a&gt;sudo apt-get install sl
&lt;/pre&gt;&lt;/div&gt;</description><category>bash</category><category>fix</category><category>ubuntu</category><category>ubuntu planet</category><guid>https://www.keypressure.com/blog/getting-rid-of-bash-annoyances/</guid><pubDate>Wed, 09 Jan 2013 12:28:00 GMT</pubDate></item><item><title>r8169 module with DKMS in Ubuntu 12.04 LTS</title><link>https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/</link><dc:creator>Roman Yepishev</dc:creator><description>&lt;p class="alert"&gt;When testing network issues with different cards it is a good idea to make sure
they actually have different chipsets.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I found no difference between the NIC operating with built-in r8169
module and the version that is available on the RealTek’s web site. You will
want to use the vendor-provided module only if your card is not supported by
the driver shipped with the linux kernel.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I packaged the source-only dkms –
&lt;a class="reference external" href="http://ubuntuone.com/0U2n8DAPd5Mm1MbCa3TXvw"&gt;r8169-6.017.00-source-only.dkms.tar.gz&lt;/a&gt;, which can be installed with:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_eece8eabc7a74099b6037689c5d49b21-1" name="rest_code_eece8eabc7a74099b6037689c5d49b21-1" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_eece8eabc7a74099b6037689c5d49b21-1"&gt;&lt;/a&gt;sudo dkms ldtarball r8169-6.017.00-source-only.dkms.tar.gz
&lt;a id="rest_code_eece8eabc7a74099b6037689c5d49b21-2" name="rest_code_eece8eabc7a74099b6037689c5d49b21-2" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_eece8eabc7a74099b6037689c5d49b21-2"&gt;&lt;/a&gt;sudo dkms build r8169/6.017.00
&lt;a id="rest_code_eece8eabc7a74099b6037689c5d49b21-3" name="rest_code_eece8eabc7a74099b6037689c5d49b21-3" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_eece8eabc7a74099b6037689c5d49b21-3"&gt;&lt;/a&gt;sudo dkms install r8169/6.017.00
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: See the end of the post, patch is required for DGE-528T to be
picked by this module.&lt;/p&gt;
&lt;p&gt;I had a complex VM network setup with separate vlan on the router for virtual
machines and second network card in the server to prevent connection hanging
when network topology was changing on the VM startup. Then I decided to
simplify the network and use one NIC only, in my case that would be &lt;a class="reference external" href="http://www.dlink.com/uk/en/business-solutions/switching/network-and-switch-accessories/nic-cards-and-media-converters/dge-528t-dge-528t-copper-gigabit-pci-card-for-pc"&gt;DLink
DGE-528T&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This card is driven by realtek 8169 chip and for some reason these like to drop
network connection. I’ve found quite a few topics on poor performance of 8169
with in-kernel driver, but the built-in r8168 chip running under r8169 driver
included in the kernel performs &lt;a class="reference external" href="http://unixblogger.wordpress.com/2011/10/18/the-pain-of-an-realtek-rtl8111rtl8168-ethernet-card/"&gt;way worse&lt;/a&gt; than r8169.&lt;/p&gt;
&lt;p&gt;There is a driver update on the &lt;a class="reference external" href="http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&amp;amp;PNid=13&amp;amp;PFid=4&amp;amp;Level=5&amp;amp;Conn=4&amp;amp;DownTypeID=3&amp;amp;GetDown=false&amp;amp;Downloads=true#92"&gt;Realtek web site&lt;/a&gt; so I decided to give it a try.&lt;/p&gt;
&lt;p&gt;I started with dkms.conf from &lt;a class="reference external" href="http://djlab.com/2010/10/fixing-rtl8111-8168b-driver-debian-ubuntu/"&gt;Fixing RTL8111/8168B kernel module on
Debian/Ubuntu post by Randy&lt;/a&gt;, but for some reason r8169 module kept overwriting
the system wide one. It turns out that Makefile installs module automatically
when called with no specific target.&lt;/p&gt;
&lt;p&gt;So here’s how I made it work:&lt;/p&gt;
&lt;ol class="arabic"&gt;
&lt;li&gt;&lt;p&gt;Download the tarball from &lt;a class="reference external" href="http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&amp;amp;PNid=13&amp;amp;PFid=4&amp;amp;Level=5&amp;amp;Conn=4&amp;amp;DownTypeID=3&amp;amp;GetDown=false&amp;amp;Downloads=true#92"&gt;Realtek web site&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unpack the resulting &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;r8169-6.017.00.tar.bz2&lt;/span&gt;&lt;/code&gt; to &lt;code class="docutils literal"&gt;/usr/src&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the &lt;code class="docutils literal"&gt;dkms.conf&lt;/code&gt; file to &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;/usr/src/r8169-6.017.00/&lt;/span&gt;&lt;/code&gt;:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_9c80f445ad6544f98d800d280e02c4f7-1" name="rest_code_9c80f445ad6544f98d800d280e02c4f7-1" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9c80f445ad6544f98d800d280e02c4f7-1"&gt;&lt;/a&gt;PACKAGE_NAME="r8169"
&lt;a id="rest_code_9c80f445ad6544f98d800d280e02c4f7-2" name="rest_code_9c80f445ad6544f98d800d280e02c4f7-2" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9c80f445ad6544f98d800d280e02c4f7-2"&gt;&lt;/a&gt;PACKAGE_VERSION="6.017.00"
&lt;a id="rest_code_9c80f445ad6544f98d800d280e02c4f7-3" name="rest_code_9c80f445ad6544f98d800d280e02c4f7-3" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9c80f445ad6544f98d800d280e02c4f7-3"&gt;&lt;/a&gt;CLEAN="make clean"
&lt;a id="rest_code_9c80f445ad6544f98d800d280e02c4f7-4" name="rest_code_9c80f445ad6544f98d800d280e02c4f7-4" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9c80f445ad6544f98d800d280e02c4f7-4"&gt;&lt;/a&gt;BUILT_MODULE_NAME[0]="r8169"
&lt;a id="rest_code_9c80f445ad6544f98d800d280e02c4f7-5" name="rest_code_9c80f445ad6544f98d800d280e02c4f7-5" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9c80f445ad6544f98d800d280e02c4f7-5"&gt;&lt;/a&gt;BUILT_MODULE_LOCATION[0]="src"
&lt;a id="rest_code_9c80f445ad6544f98d800d280e02c4f7-6" name="rest_code_9c80f445ad6544f98d800d280e02c4f7-6" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9c80f445ad6544f98d800d280e02c4f7-6"&gt;&lt;/a&gt;DEST_MODULE_LOCATION[0]="/updates"
&lt;a id="rest_code_9c80f445ad6544f98d800d280e02c4f7-7" name="rest_code_9c80f445ad6544f98d800d280e02c4f7-7" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9c80f445ad6544f98d800d280e02c4f7-7"&gt;&lt;/a&gt;MAKE[0]="'make' 'modules'"
&lt;a id="rest_code_9c80f445ad6544f98d800d280e02c4f7-8" name="rest_code_9c80f445ad6544f98d800d280e02c4f7-8" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9c80f445ad6544f98d800d280e02c4f7-8"&gt;&lt;/a&gt;AUTOINSTALL="YES"
&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build and install the module:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_2844e11b34114f69a9a3e17a3e88e945-1" name="rest_code_2844e11b34114f69a9a3e17a3e88e945-1" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_2844e11b34114f69a9a3e17a3e88e945-1"&gt;&lt;/a&gt;$ sudo dkms install r8169/6.017.00
&lt;a id="rest_code_2844e11b34114f69a9a3e17a3e88e945-2" name="rest_code_2844e11b34114f69a9a3e17a3e88e945-2" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_2844e11b34114f69a9a3e17a3e88e945-2"&gt;&lt;/a&gt;...
&lt;a id="rest_code_2844e11b34114f69a9a3e17a3e88e945-3" name="rest_code_2844e11b34114f69a9a3e17a3e88e945-3" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_2844e11b34114f69a9a3e17a3e88e945-3"&gt;&lt;/a&gt; - Installation
&lt;a id="rest_code_2844e11b34114f69a9a3e17a3e88e945-4" name="rest_code_2844e11b34114f69a9a3e17a3e88e945-4" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_2844e11b34114f69a9a3e17a3e88e945-4"&gt;&lt;/a&gt;   - Installing to /lib/modules/3.2.0-35-generic/updates/dkms/
&lt;a id="rest_code_2844e11b34114f69a9a3e17a3e88e945-5" name="rest_code_2844e11b34114f69a9a3e17a3e88e945-5" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_2844e11b34114f69a9a3e17a3e88e945-5"&gt;&lt;/a&gt;...
&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;At the moment due to the bug in dkms script it is not possible to create the
dkms tarball directly from realtek sources but you can create one after you
perform the steps above.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_9385e17a07354e0da8d3de73e53ec088-1" name="rest_code_9385e17a07354e0da8d3de73e53ec088-1" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9385e17a07354e0da8d3de73e53ec088-1"&gt;&lt;/a&gt;$ sudo dkms mktarball r8169/6.017.00
&lt;a id="rest_code_9385e17a07354e0da8d3de73e53ec088-2" name="rest_code_9385e17a07354e0da8d3de73e53ec088-2" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9385e17a07354e0da8d3de73e53ec088-2"&gt;&lt;/a&gt;Marking modules for 3.2.0-35-generic (x86_64) for archiving...
&lt;a id="rest_code_9385e17a07354e0da8d3de73e53ec088-3" name="rest_code_9385e17a07354e0da8d3de73e53ec088-3" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9385e17a07354e0da8d3de73e53ec088-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_9385e17a07354e0da8d3de73e53ec088-4" name="rest_code_9385e17a07354e0da8d3de73e53ec088-4" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9385e17a07354e0da8d3de73e53ec088-4"&gt;&lt;/a&gt;Marking /var/lib/dkms/r8169/6.017.00/source for archiving...
&lt;a id="rest_code_9385e17a07354e0da8d3de73e53ec088-5" name="rest_code_9385e17a07354e0da8d3de73e53ec088-5" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9385e17a07354e0da8d3de73e53ec088-5"&gt;&lt;/a&gt;
&lt;a id="rest_code_9385e17a07354e0da8d3de73e53ec088-6" name="rest_code_9385e17a07354e0da8d3de73e53ec088-6" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_9385e17a07354e0da8d3de73e53ec088-6"&gt;&lt;/a&gt;Tarball location: /var/lib/dkms/r8169/6.017.00/tarball//r8169-6.017.00-kernel3.2.0-35-generic-x86_64.dkms.tar.gz
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Afterwards you can load this tarbal on a different machine:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-1" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-1" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-1"&gt;&lt;/a&gt;$ sudo dkms ldtarball r8169-6.017.00-kernel3.2.0-35-generic-x86_64.dkms.tar.gz
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-2" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-2" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-2"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-3" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-3" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-3"&gt;&lt;/a&gt;Loading tarball for r8169-6.017.00
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-4" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-4" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-4"&gt;&lt;/a&gt;Loading /var/lib/dkms/r8169/6.017.00/3.2.0-35-generic/x86_64...
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-5" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-5" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-5"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-6" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-6" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-6"&gt;&lt;/a&gt;DKMS: ldtarball completed.
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-7" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-7" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-8" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-8" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-8"&gt;&lt;/a&gt;Creating symlink /var/lib/dkms/r8169/6.017.00/source -&amp;gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-9" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-9" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-9"&gt;&lt;/a&gt;                /usr/src/r8169-6.017.00
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-10" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-10" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-10"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-11" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-11" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-11"&gt;&lt;/a&gt;DKMS: add completed.
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-12" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-12" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-12"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-13" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-13" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-13"&gt;&lt;/a&gt;$ sudo dkms install r8169/6.017.00
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-14" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-14" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-14"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-15" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-15" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-15"&gt;&lt;/a&gt;Creating symlink /var/lib/dkms/r8169/6.017.00/source -&amp;gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-16" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-16" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-16"&gt;&lt;/a&gt;                /usr/src/r8169-6.017.00
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-17" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-17" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-17"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-18" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-18" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-18"&gt;&lt;/a&gt;DKMS: add completed.
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-19" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-19" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-19"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-20" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-20" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-20"&gt;&lt;/a&gt;Kernel preparation unnecessary for this kernel.  Skipping...
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-21" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-21" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-21"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-22" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-22" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-22"&gt;&lt;/a&gt;Building module:
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-23" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-23" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-23"&gt;&lt;/a&gt;cleaning build area....
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-24" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-24" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-24"&gt;&lt;/a&gt;'make' 'modules'....
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-25" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-25" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-25"&gt;&lt;/a&gt;cleaning build area....
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-26" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-26" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-26"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-27" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-27" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-27"&gt;&lt;/a&gt;DKMS: build completed.
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-28" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-28" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-28"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-29" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-29" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-29"&gt;&lt;/a&gt;r8169.ko:
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-30" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-30" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-30"&gt;&lt;/a&gt;Running module version sanity check.
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-31" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-31" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-31"&gt;&lt;/a&gt;- Original module
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-32" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-32" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-32"&gt;&lt;/a&gt;- Installation
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-33" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-33" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-33"&gt;&lt;/a&gt;- Installing to /lib/modules/3.2.0-35-generic/updates/dkms/
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-34" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-34" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-34"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-35" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-35" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-35"&gt;&lt;/a&gt;depmod....
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-36" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-36" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-36"&gt;&lt;/a&gt;
&lt;a id="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-37" name="rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-37" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_bfb7afbbb8e04e7fa99b372e2c47e633-37"&gt;&lt;/a&gt;DKMS: install completed.
&lt;/pre&gt;&lt;/div&gt;
&lt;section id="dge-528t"&gt;
&lt;h2&gt;DGE-528T&lt;/h2&gt;
&lt;p&gt;So I left this module running for about a week and yesterday I could not make
the card work after a reboot. It turns out that while the updated r8169 module
&lt;em&gt;is&lt;/em&gt; installed, it is not being used for D-Link DGE-528T card.&lt;/p&gt;
&lt;p&gt;&lt;code class="docutils literal"&gt;r8169_n.c&lt;/code&gt; contains the following:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code c"&gt;&lt;a id="rest_code_41f3b210d8724980af242a41f20e0522-1" name="rest_code_41f3b210d8724980af242a41f20e0522-1" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_41f3b210d8724980af242a41f20e0522-1"&gt;&lt;/a&gt;&lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;struct&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;pci_device_id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rtl8169_pci_tbl&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_41f3b210d8724980af242a41f20e0522-2" name="rest_code_41f3b210d8724980af242a41f20e0522-2" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_41f3b210d8724980af242a41f20e0522-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;PCI_DEVICE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PCI_VENDOR_ID_REALTEK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mh"&gt;0x8167&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;RTL_CFG_0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;a id="rest_code_41f3b210d8724980af242a41f20e0522-3" name="rest_code_41f3b210d8724980af242a41f20e0522-3" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_41f3b210d8724980af242a41f20e0522-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;PCI_DEVICE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PCI_VENDOR_ID_REALTEK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mh"&gt;0x8169&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;RTL_CFG_0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;a id="rest_code_41f3b210d8724980af242a41f20e0522-4" name="rest_code_41f3b210d8724980af242a41f20e0522-4" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_41f3b210d8724980af242a41f20e0522-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;PCI_VENDOR_ID_DLINK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0x4300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;PCI_VENDOR_ID_DLINK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0x4c00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;RTL_CFG_0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;a id="rest_code_41f3b210d8724980af242a41f20e0522-5" name="rest_code_41f3b210d8724980af242a41f20e0522-5" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_41f3b210d8724980af242a41f20e0522-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,},&lt;/span&gt;
&lt;a id="rest_code_41f3b210d8724980af242a41f20e0522-6" name="rest_code_41f3b210d8724980af242a41f20e0522-6" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_41f3b210d8724980af242a41f20e0522-6"&gt;&lt;/a&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So the module does not match &lt;code class="docutils literal"&gt;PCI_VENDOR_ID_DLINK:0x4c00&lt;/code&gt; subsystem (&lt;code class="docutils literal"&gt;lspci &lt;span class="pre"&gt;-vnn&lt;/span&gt;&lt;/code&gt;):&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_70399a43075a483f952c5c2781ab31a8-1" name="rest_code_70399a43075a483f952c5c2781ab31a8-1" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_70399a43075a483f952c5c2781ab31a8-1"&gt;&lt;/a&gt;02:06.0 Ethernet controller [0200]: D-Link System Inc DGE-528T Gigabit Ethernet Adapter [1186:4300] (rev 10)
&lt;a id="rest_code_70399a43075a483f952c5c2781ab31a8-2" name="rest_code_70399a43075a483f952c5c2781ab31a8-2" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_70399a43075a483f952c5c2781ab31a8-2"&gt;&lt;/a&gt;    Subsystem: D-Link System Inc DGE-528T Gigabit Ethernet Adapter [1186:4300]
&lt;a id="rest_code_70399a43075a483f952c5c2781ab31a8-3" name="rest_code_70399a43075a483f952c5c2781ab31a8-3" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_70399a43075a483f952c5c2781ab31a8-3"&gt;&lt;/a&gt;    Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 21
&lt;a id="rest_code_70399a43075a483f952c5c2781ab31a8-4" name="rest_code_70399a43075a483f952c5c2781ab31a8-4" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_70399a43075a483f952c5c2781ab31a8-4"&gt;&lt;/a&gt;    I/O ports at e800 [size=256]
&lt;a id="rest_code_70399a43075a483f952c5c2781ab31a8-5" name="rest_code_70399a43075a483f952c5c2781ab31a8-5" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_70399a43075a483f952c5c2781ab31a8-5"&gt;&lt;/a&gt;    Memory at febffc00 (32-bit, non-prefetchable) [size=256]
&lt;a id="rest_code_70399a43075a483f952c5c2781ab31a8-6" name="rest_code_70399a43075a483f952c5c2781ab31a8-6" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_70399a43075a483f952c5c2781ab31a8-6"&gt;&lt;/a&gt;    Expansion ROM at febc0000 [disabled] [size=128K]
&lt;a id="rest_code_70399a43075a483f952c5c2781ab31a8-7" name="rest_code_70399a43075a483f952c5c2781ab31a8-7" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_70399a43075a483f952c5c2781ab31a8-7"&gt;&lt;/a&gt;    Capabilities: [dc] Power Management version 2
&lt;a id="rest_code_70399a43075a483f952c5c2781ab31a8-8" name="rest_code_70399a43075a483f952c5c2781ab31a8-8" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_70399a43075a483f952c5c2781ab31a8-8"&gt;&lt;/a&gt;    Kernel driver in use: r8169
&lt;a id="rest_code_70399a43075a483f952c5c2781ab31a8-9" name="rest_code_70399a43075a483f952c5c2781ab31a8-9" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_70399a43075a483f952c5c2781ab31a8-9"&gt;&lt;/a&gt;    Kernel modules: r8169
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;a class="reference external" href="http://pci-ids.ucw.cz/read/PC/1186/4c00/11864c00"&gt;1186:4c00&lt;/a&gt; is actually a DGE-T530 card, but it looks like there are some
DGE-T528 cards with &lt;code class="docutils literal"&gt;1186:4300&lt;/code&gt; subsystem and some have &lt;code class="docutils literal"&gt;1186:4c00&lt;/code&gt; one. The
original driver from D-Link has &lt;code class="docutils literal"&gt;PCI_ANY_ID&lt;/code&gt; for subsystem fields so it looks
like these are compatible.&lt;/p&gt;
&lt;p&gt;I was so sure the updated module would fix the issues I was having with the
network card that it actually stopped misbehaving.&lt;/p&gt;
&lt;p&gt;However, I decided to patch the module to make it work with my card too:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code diff"&gt;&lt;a id="rest_code_e144279fb12649cdb07448493a758443-1" name="rest_code_e144279fb12649cdb07448493a758443-1" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_e144279fb12649cdb07448493a758443-1"&gt;&lt;/a&gt;&lt;span class="gd"&gt;--- r8169_n.c.ori   2012-05-03 15:23:12.000000000 +0300&lt;/span&gt;
&lt;a id="rest_code_e144279fb12649cdb07448493a758443-2" name="rest_code_e144279fb12649cdb07448493a758443-2" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_e144279fb12649cdb07448493a758443-2"&gt;&lt;/a&gt;&lt;span class="gi"&gt;+++ r8169_n.c   2012-12-30 19:42:14.818322918 +0200&lt;/span&gt;
&lt;a id="rest_code_e144279fb12649cdb07448493a758443-3" name="rest_code_e144279fb12649cdb07448493a758443-3" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_e144279fb12649cdb07448493a758443-3"&gt;&lt;/a&gt;&lt;span class="gu"&gt;@@ -115,7 +115,8 @@&lt;/span&gt;
&lt;a id="rest_code_e144279fb12649cdb07448493a758443-4" name="rest_code_e144279fb12649cdb07448493a758443-4" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_e144279fb12649cdb07448493a758443-4"&gt;&lt;/a&gt;static struct pci_device_id rtl8169_pci_tbl[] = {
&lt;a id="rest_code_e144279fb12649cdb07448493a758443-5" name="rest_code_e144279fb12649cdb07448493a758443-5" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_e144279fb12649cdb07448493a758443-5"&gt;&lt;/a&gt;&lt;span class="w"&gt; &lt;/span&gt;   { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 },
&lt;a id="rest_code_e144279fb12649cdb07448493a758443-6" name="rest_code_e144279fb12649cdb07448493a758443-6" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_e144279fb12649cdb07448493a758443-6"&gt;&lt;/a&gt;&lt;span class="w"&gt; &lt;/span&gt;   { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 },
&lt;a id="rest_code_e144279fb12649cdb07448493a758443-7" name="rest_code_e144279fb12649cdb07448493a758443-7" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_e144279fb12649cdb07448493a758443-7"&gt;&lt;/a&gt;&lt;span class="gd"&gt;-   { PCI_VENDOR_ID_DLINK, 0x4300, PCI_VENDOR_ID_DLINK, 0x4c00, 0, 0, RTL_CFG_0 },&lt;/span&gt;
&lt;a id="rest_code_e144279fb12649cdb07448493a758443-8" name="rest_code_e144279fb12649cdb07448493a758443-8" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_e144279fb12649cdb07448493a758443-8"&gt;&lt;/a&gt;&lt;span class="gi"&gt;+   { PCI_DEVICE(PCI_VENDOR_ID_DLINK,       0x4300), 0, 0, RTL_CFG_0 },&lt;/span&gt;
&lt;a id="rest_code_e144279fb12649cdb07448493a758443-9" name="rest_code_e144279fb12649cdb07448493a758443-9" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_e144279fb12649cdb07448493a758443-9"&gt;&lt;/a&gt;&lt;span class="gi"&gt;+   //{ PCI_VENDOR_ID_DLINK, 0x4300, PCI_VENDOR_ID_DLINK, 0x4c00, 0, 0, RTL_CFG_0 },&lt;/span&gt;
&lt;a id="rest_code_e144279fb12649cdb07448493a758443-10" name="rest_code_e144279fb12649cdb07448493a758443-10" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_e144279fb12649cdb07448493a758443-10"&gt;&lt;/a&gt;&lt;span class="w"&gt; &lt;/span&gt;   {0,},
&lt;a id="rest_code_e144279fb12649cdb07448493a758443-11" name="rest_code_e144279fb12649cdb07448493a758443-11" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_e144279fb12649cdb07448493a758443-11"&gt;&lt;/a&gt;};
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And now the module prints the following when loaded:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_4eb7c209ee004697a34809ce41b7468b-1" name="rest_code_4eb7c209ee004697a34809ce41b7468b-1" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_4eb7c209ee004697a34809ce41b7468b-1"&gt;&lt;/a&gt;[18014.031288] r8169 Gigabit Ethernet driver 6.017.00-NAPI loaded
&lt;a id="rest_code_4eb7c209ee004697a34809ce41b7468b-2" name="rest_code_4eb7c209ee004697a34809ce41b7468b-2" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_4eb7c209ee004697a34809ce41b7468b-2"&gt;&lt;/a&gt;[18014.031344] r8169 0000:02:06.0: PCI INT A -&amp;gt; GSI 21 (level, low) -&amp;gt; IRQ 21
&lt;a id="rest_code_4eb7c209ee004697a34809ce41b7468b-3" name="rest_code_4eb7c209ee004697a34809ce41b7468b-3" href="https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/#rest_code_4eb7c209ee004697a34809ce41b7468b-3"&gt;&lt;/a&gt;[18014.033537] r8169: This product is covered by one or more of the following patents: US5,307,459, US5,434,872, US5,732,094, US6,570,884, US6,115,776, and US6,327,625.
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So now I am really testing the module provided by Realtek.&lt;/p&gt;
&lt;/section&gt;</description><category>dkms</category><category>fix</category><category>precise</category><category>realtek</category><category>the-hard-way</category><category>ubuntu</category><guid>https://www.keypressure.com/blog/r8169-dkms-ubuntu-12-04/</guid><pubDate>Tue, 18 Dec 2012 13:04:00 GMT</pubDate></item><item><title>When localhost is not</title><link>https://www.keypressure.com/blog/when-localhost-is-not/</link><dc:creator>Roman Yepishev</dc:creator><description>&lt;p&gt;&lt;code class="docutils literal"&gt;/etc/hosts&lt;/code&gt; is a file where these entries should never be touched:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_b1c1e8954d1441cf8018198f1be3a652-1" name="rest_code_b1c1e8954d1441cf8018198f1be3a652-1" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_b1c1e8954d1441cf8018198f1be3a652-1"&gt;&lt;/a&gt;127.0.0.1       localhost
&lt;a id="rest_code_b1c1e8954d1441cf8018198f1be3a652-2" name="rest_code_b1c1e8954d1441cf8018198f1be3a652-2" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_b1c1e8954d1441cf8018198f1be3a652-2"&gt;&lt;/a&gt;::1             ip6-localhost ip6-loopback
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;However, during my last trip to my VPS to fix my mail system after
&lt;a class="reference external" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/"&gt;opendkim update in Ubuntu 10.04&lt;/a&gt;
I found something interesting in netstat:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_0a61d08c0138459d9d0a6c9116996722-1" name="rest_code_0a61d08c0138459d9d0a6c9116996722-1" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_0a61d08c0138459d9d0a6c9116996722-1"&gt;&lt;/a&gt;$ sudo netstat -lntp
&lt;a id="rest_code_0a61d08c0138459d9d0a6c9116996722-2" name="rest_code_0a61d08c0138459d9d0a6c9116996722-2" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_0a61d08c0138459d9d0a6c9116996722-2"&gt;&lt;/a&gt;Active Internet connections (only servers)
&lt;a id="rest_code_0a61d08c0138459d9d0a6c9116996722-3" name="rest_code_0a61d08c0138459d9d0a6c9116996722-3" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_0a61d08c0138459d9d0a6c9116996722-3"&gt;&lt;/a&gt;Proto Recv-Q Send-Q Local Address        ... PID/Program name
&lt;a id="rest_code_0a61d08c0138459d9d0a6c9116996722-4" name="rest_code_0a61d08c0138459d9d0a6c9116996722-4" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_0a61d08c0138459d9d0a6c9116996722-4"&gt;&lt;/a&gt;...
&lt;a id="rest_code_0a61d08c0138459d9d0a6c9116996722-5" name="rest_code_0a61d08c0138459d9d0a6c9116996722-5" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_0a61d08c0138459d9d0a6c9116996722-5"&gt;&lt;/a&gt;tcp        0      0 173.212.238.58:8891  ... 15410/opendkim
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Basically, when I specified &lt;code class="docutils literal"&gt;localhost&lt;/code&gt; in opendkim configuration, it was
listening on a public interface instead. Pinging localhost revealed it is
actually a non-loopback address:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_87452396482840f69846121a40bcaba8-1" name="rest_code_87452396482840f69846121a40bcaba8-1" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_87452396482840f69846121a40bcaba8-1"&gt;&lt;/a&gt;$ ping localhost
&lt;a id="rest_code_87452396482840f69846121a40bcaba8-2" name="rest_code_87452396482840f69846121a40bcaba8-2" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_87452396482840f69846121a40bcaba8-2"&gt;&lt;/a&gt;PING yankee.lappyfamily.net (173.212.238.58) 56(84) bytes of data.
&lt;a id="rest_code_87452396482840f69846121a40bcaba8-3" name="rest_code_87452396482840f69846121a40bcaba8-3" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_87452396482840f69846121a40bcaba8-3"&gt;&lt;/a&gt;...
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It looks like it’s been this way since the very begninning, as my
&lt;code class="docutils literal"&gt;/etc/hosts&lt;/code&gt; had the following:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_171afa7c06a14ae2bbf094fd06a588dd-1" name="rest_code_171afa7c06a14ae2bbf094fd06a588dd-1" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_171afa7c06a14ae2bbf094fd06a588dd-1"&gt;&lt;/a&gt;# Auto-generated hostname. Please do not remove this comment.
&lt;a id="rest_code_171afa7c06a14ae2bbf094fd06a588dd-2" name="rest_code_171afa7c06a14ae2bbf094fd06a588dd-2" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_171afa7c06a14ae2bbf094fd06a588dd-2"&gt;&lt;/a&gt;173.212.238.58 yankee.lappyfamily.net  yankee localhost 204538 localhost.localdomain
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And this was clearly a misconfiguration (I am sure 204538 is a good hostname).&lt;/p&gt;
&lt;p&gt;I looked at my local Ubuntu installation and updated the VPS so that the hosts
file became:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_3d91975ab835430282d3b7bacc987d84-1" name="rest_code_3d91975ab835430282d3b7bacc987d84-1" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_3d91975ab835430282d3b7bacc987d84-1"&gt;&lt;/a&gt;127.0.0.1 localhost
&lt;a id="rest_code_3d91975ab835430282d3b7bacc987d84-2" name="rest_code_3d91975ab835430282d3b7bacc987d84-2" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_3d91975ab835430282d3b7bacc987d84-2"&gt;&lt;/a&gt;::1 ip6-localhost ip6-loopback
&lt;a id="rest_code_3d91975ab835430282d3b7bacc987d84-3" name="rest_code_3d91975ab835430282d3b7bacc987d84-3" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_3d91975ab835430282d3b7bacc987d84-3"&gt;&lt;/a&gt;# Auto-generated hostname. Please do not remove this comment.
&lt;a id="rest_code_3d91975ab835430282d3b7bacc987d84-4" name="rest_code_3d91975ab835430282d3b7bacc987d84-4" href="https://www.keypressure.com/blog/when-localhost-is-not/#rest_code_3d91975ab835430282d3b7bacc987d84-4"&gt;&lt;/a&gt;173.212.238.58 yankee.lappyfamily.net  yankee
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After this I restarted all the applications that were supposed to listen on
the loopback interface and verified the fix with &lt;code class="docutils literal"&gt;netstat&lt;/code&gt; again.&lt;/p&gt;
&lt;p&gt;First of all, you need to have a firewall configured on your servers and allow
only trusted incoming connections to trusted applications. This is what
prevented my opendkim installation from accepting the incoming requests from
the internet.&lt;/p&gt;
&lt;p&gt;Second, you need to verify that &lt;code class="docutils literal"&gt;localhost&lt;/code&gt; actually refers to the loopback
interface and does not resolve to your public one, as you have a fully
qualified name for that purpose.&lt;/p&gt;
&lt;p&gt;I found that now the control panel for the VPS I am using correctly generates
the hostname line, but it may not have been the case a year ago when I got the
VPS first configured.&lt;/p&gt;</description><category>lucid</category><category>security</category><category>ubuntu</category><category>ubuntu planet</category><category>vps</category><guid>https://www.keypressure.com/blog/when-localhost-is-not/</guid><pubDate>Thu, 06 Dec 2012 15:07:00 GMT</pubDate></item><item><title>Importing disqus comments into WordPress</title><link>https://www.keypressure.com/blog/disqus-into-wordpress/</link><dc:creator>Roman Yepishev</dc:creator><description>&lt;figure&gt;
&lt;img alt="/galleries/dropbox/disqus2wp1.png" src="https://www.keypressure.com/galleries/dropbox/disqus2wp1.png"&gt;
&lt;/figure&gt;
&lt;p&gt;Long story short: this is not trivial.&lt;/p&gt;
&lt;p&gt;Disqus is a popular service that provides commenting functionality. All you
need to do for your HTML page to have embedded discussion is to add a bit of
javascript.&lt;/p&gt;
&lt;p&gt;They have awesome importers from various blog engines. This blog was originally
hosted on Blogspot, migration to static blog generated by Octopress required me
to search for alternative commenting facilities and I decided to use disqus (is
there anything else, really?) Now I switched to WordPress and I wanted my
comments back.&lt;/p&gt;
&lt;p&gt;Disqus does provide the ability to export all the comments in a XML file. Quick
Google search told me that it &lt;a class="reference external" href="http://jaredhobbs.bitbucket.org/pyhacker/archive2011/convert-comments-exported-disqus-wxr/"&gt;was possible&lt;/a&gt; to get the comments quite easily
into WordPress by converting the disqus dump into WXR, but it is not really
that easy. WordPress will ignore the post if it is already there and will not
import comments. There’s a &lt;a class="reference external" href="http://wordpress.org/extend/plugins/disqus-comments-importer/"&gt;plugin that imports disqus comments&lt;/a&gt;, but I wanted
full support of nested comments and little to no PHP coding.&lt;/p&gt;
&lt;p&gt;I dumped all the wordpress database locally and hacked up a script that reads
the comments.xml file and puts the necessary data into the database. The script
needs access to some sort of a database in order to figure out the post_id for
each post and generate the comment identifiers for correct nesting.&lt;/p&gt;
&lt;script src="https://gist.github.com/4207657.js"&gt;&lt;/script&gt;&lt;noscript&gt;&lt;pre class="literal-block"&gt;#!/usr/bin/python
"""Quick and dirty hack to get disqus comments into WordPress DB"""

import sys
from datetime import datetime
from xml.etree import ElementTree as ET
import MySQLdb

ANONYMOUS_EMAIL = 'nobody@example.net'

# Database configuration
DATABASE = {
    'host': 'lab.lappyfamily.net',
    'user': 'rtg',
    'name': 'rtginua6_wp1',
}

# Admin information
ADMIN_INFO = {
    'comment_author': 'Roman Yepishev',
    'comment_author_email': 'roman.yepishev@yandex.ua',
    'user_id': 1
}

# Names used in disqus that represent administrator
ADMIN_ALIASES = set(['rtg', 'Roman', 'rye'])

class DisqusImporter(object):
    """
    Imports Disqus XML into MySQL database for WordPress
    """
    def __init__(self):
        self.wpdb = MySQLdb.connect(host=DATABASE['host'],
                                    user=DATABASE['user'],
                                    db=DATABASE['name'],
                                    charset='utf8')

        self.wp_post_url_to_id = {}

    def make_wordpress_url_map(self):
        """Creates URL-&amp;gt;ID map for WordPress URLS"""
        cursor = self.wpdb.cursor()

        cursor.execute("""
            SELECT 
                guid, id
            FROM
                wp_posts
            WHERE
                post_type = 'post'
        """)

        for row in cursor:
            self.wp_post_url_to_id[row[0]] = row[1]

    def parse_disqus_comments(self, path):
        """Parse comments creating WP-like structure"""

        NS = '{http://disqus.com}'
        NS_DI = '{http://disqus.com/disqus-internals}'

        tree = ET.parse(path)
        root = tree.getroot()

        comments = {}
        thread_id_to_url = {}

        # Gathering post threads identifiers.
        # Each thread corresponds to a blog post
        for thread in root.findall(NS + 'thread'):
            dsq_id =  thread.attrib[NS_DI + 'id']
            link = thread.find(NS + 'link')

            thread_id_to_url[dsq_id] = link.text

        # Parsing posts
        for post in root.findall(NS + 'post'):
            dsq_id = post.attrib[NS_DI + 'id']

            thread_id = post.find(NS + 'thread').attrib[NS_DI + 'id']

            # If we don't have the mapping from post to
            # WordPress post ID, we can't # proceed with this comment
            thread_url = thread_id_to_url[thread_id]

            if thread_url not in self.wp_post_url_to_id:
                print "Skipping comment for {}".format(thread_url)
                continue

            created_at = post.find(NS + 'createdAt').text

            author = post.find(NS + 'author')
            email = author.find(NS + 'email').text
            name = author.find(NS + 'name').text

            parent = post.find(NS + 'parent')
            if parent is not None:
                parent_id = parent.attrib[NS_DI + 'id']
            else:
                parent_id = None

            # MySQL issues a warning if we stuff data in YYY-mm-ddTHH:MM:SSZ
            comment_date = datetime.strptime(created_at, '%Y-%m-%dT%H:%M:%SZ'
                                          ).strftime('%Y-%m-%d %H:%M:%S')

            
            comment_post_id = self.wp_post_url_to_id[thread_url]

            post_data = {
                'comment_post_ID': comment_post_id,
                'comment_content': post.find(NS + 'message').text,
                'comment_date': comment_date,
                'comment_date_gmt': comment_date,
                'comment_author': name,
                'comment_author_IP': post.find(NS + 'ipAddress').text,
                'comment_author_email': email if email else ANONYMOUS_EMAIL,
                'user_id': 0,
                'parent_id': parent_id,
                'children': []
            }

            # Fixup for my own comments
            if name in ADMIN_ALIASES:
                post_data.update(ADMIN_INFO)

            comments[dsq_id] = post_data

        # First pass - creating comment tree
        for comment in comments.values():
            if comment['parent_id']:
                parent_comment = comments[comment['parent_id']]
                parent_comment['children'].append(comment)

        # Second pass - dropping posts that are not toplevel
        # They are already in 'children'
        for comment_id in comments.keys():
            # If it is still here (we could have deleted it)
            if comment_id in comments:
                comment = comments[comment_id]
            else:
                continue

            if comment['parent_id']:
                del comments[comment_id]

        return comments

    def add_comment(self, comment, parent_id):
        """Add comment and all the child comments to the DB"""

        cursor = self.wpdb.cursor()

        comment['comment_parent'] = parent_id

        cursor.execute("""
                    INSERT INTO wp_comments (
                        comment_post_ID,      comment_author,
                        comment_author_email, comment_author_IP,
                        comment_date,         comment_date_gmt,
                        comment_content,      comment_parent,
                        user_id)
                    VALUES (
                        %(comment_post_ID)s, %(comment_author)s,
                        %(comment_author_email)s, %(comment_author_IP)s,
                        %(comment_date)s, %(comment_date_gmt)s,
                        %(comment_content)s, %(comment_parent)s,
                        %(user_id)s)
            """, comment
        )

        parent_id = cursor.lastrowid

        for item in comment['children']:
            self.add_comment(item, parent_id)

    def update_comment_count(self):
        """
        Synchronizes cached comment count with the actual number of
        comments
        """
        cursor = self.wpdb.cursor()
        # Update post counts
        cursor.execute("""
                UPDATE 
                    wp_posts AS p
                    LEFT JOIN (
                        SELECT 
                            comment_post_ID,
                            count(comment_post_ID) as comment_count
                        FROM
                            wp_comments
                        WHERE
                            comment_approved = '1'
                        GROUP BY comment_post_ID
                    ) as c 
                ON 
                    p.id = c.comment_post_ID
                SET
                    p.comment_count = c.comment_count
                WHERE
                    p.id = c.comment_post_ID
        """)

    def main(self, path):
        """Entry point"""
        self.make_wordpress_url_map()
        comments = self.parse_disqus_comments(path)

        for item in comments.values():
            self.add_comment(item, 0)

        self.update_comment_count()

if __name__ == "__main__":
    importer = DisqusImporter()
    importer.main(sys.argv[1])&lt;/pre&gt;
&lt;/noscript&gt;&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-1" name="rest_code_175c870001214557b3f4a205918c7c48-1" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-1"&gt;&lt;/a&gt;&lt;span class="o"&gt;...&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-2" name="rest_code_175c870001214557b3f4a205918c7c48-2" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-2"&gt;&lt;/a&gt;&lt;span class="n"&gt;ANONYMOUS_EMAIL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'nobody@example.net'&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-3" name="rest_code_175c870001214557b3f4a205918c7c48-3" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-4" name="rest_code_175c870001214557b3f4a205918c7c48-4" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-4"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# Database configuration&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-5" name="rest_code_175c870001214557b3f4a205918c7c48-5" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-5"&gt;&lt;/a&gt;&lt;span class="n"&gt;DATABASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-6" name="rest_code_175c870001214557b3f4a205918c7c48-6" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-6"&gt;&lt;/a&gt;    &lt;span class="s1"&gt;'host'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'lab.lappyfamily.net'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-7" name="rest_code_175c870001214557b3f4a205918c7c48-7" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-7"&gt;&lt;/a&gt;    &lt;span class="s1"&gt;'user'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'rtg'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-8" name="rest_code_175c870001214557b3f4a205918c7c48-8" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-8"&gt;&lt;/a&gt;    &lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'rtginua6_wp1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-9" name="rest_code_175c870001214557b3f4a205918c7c48-9" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-9"&gt;&lt;/a&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-10" name="rest_code_175c870001214557b3f4a205918c7c48-10" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-10"&gt;&lt;/a&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-11" name="rest_code_175c870001214557b3f4a205918c7c48-11" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-11"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# Admin information&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-12" name="rest_code_175c870001214557b3f4a205918c7c48-12" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-12"&gt;&lt;/a&gt;&lt;span class="n"&gt;ADMIN_INFO&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-13" name="rest_code_175c870001214557b3f4a205918c7c48-13" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-13"&gt;&lt;/a&gt;    &lt;span class="s1"&gt;'comment_author'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Roman Yepishev'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-14" name="rest_code_175c870001214557b3f4a205918c7c48-14" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-14"&gt;&lt;/a&gt;    &lt;span class="s1"&gt;'comment_author_email'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'roman.yepishev@yandex.ua'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-15" name="rest_code_175c870001214557b3f4a205918c7c48-15" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-15"&gt;&lt;/a&gt;    &lt;span class="s1"&gt;'user_id'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-16" name="rest_code_175c870001214557b3f4a205918c7c48-16" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-16"&gt;&lt;/a&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-17" name="rest_code_175c870001214557b3f4a205918c7c48-17" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-17"&gt;&lt;/a&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-18" name="rest_code_175c870001214557b3f4a205918c7c48-18" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-18"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# Names used in disqus that represent administrator&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-19" name="rest_code_175c870001214557b3f4a205918c7c48-19" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-19"&gt;&lt;/a&gt;&lt;span class="n"&gt;ADMIN_ALIASES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'rtg'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Roman'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'rye'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;a id="rest_code_175c870001214557b3f4a205918c7c48-20" name="rest_code_175c870001214557b3f4a205918c7c48-20" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_175c870001214557b3f4a205918c7c48-20"&gt;&lt;/a&gt;&lt;span class="o"&gt;...&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And the script itself runs on an uncompressed disqus XML. The script will skip all pages that it could not find the URLs for:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_3f90ada2b2d542c3826d0fdb362c8d8b-1" name="rest_code_3f90ada2b2d542c3826d0fdb362c8d8b-1" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_3f90ada2b2d542c3826d0fdb362c8d8b-1"&gt;&lt;/a&gt;$ python wp-import-disqus.py comments.xml
&lt;a id="rest_code_3f90ada2b2d542c3826d0fdb362c8d8b-2" name="rest_code_3f90ada2b2d542c3826d0fdb362c8d8b-2" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_3f90ada2b2d542c3826d0fdb362c8d8b-2"&gt;&lt;/a&gt;Skipping comment for http://rtg.in.ua/app/acer-exif-fixup/index.html
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After script finished I dumped the comments table and uploaded it via the phpmyadmin interface.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_34cf685120af4a899fa41ee6ba96dfd2-1" name="rest_code_34cf685120af4a899fa41ee6ba96dfd2-1" href="https://www.keypressure.com/blog/disqus-into-wordpress/#rest_code_34cf685120af4a899fa41ee6ba96dfd2-1"&gt;&lt;/a&gt;$ mysqldump -h lab rtginua6_wp1 wp_comments &amp;gt; wp_comments.sql
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This resulted in all 140 comments being correctly imported in a correct encoding and properly nested.&lt;/p&gt;
&lt;p&gt;If you happen to know a better way to import comments, feel free to provide the links to alternative solutions.&lt;/p&gt;</description><category>linux</category><category>mysql</category><category>python</category><category>the-hard-way</category><category>ubuntu</category><category>wordpress</category><guid>https://www.keypressure.com/blog/disqus-into-wordpress/</guid><pubDate>Tue, 04 Dec 2012 21:43:00 GMT</pubDate></item><item><title>opendkim update in Lucid 10.04 LTS</title><link>https://www.keypressure.com/blog/opendkim-update-in-lucid/</link><dc:creator>Roman Yepishev</dc:creator><description>&lt;p&gt;A few days ago I decided to upgrade the packages on my Lucid VPS and today I
noticed that there is a queue of unsent messages on my VM host with “Service
unavailable” response from my mail relay on the VPS host.&lt;/p&gt;
&lt;p&gt;Upon closer examination I found that the mail log was full of:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_21f35023835347498ae4e2706805c1ff-1" name="rest_code_21f35023835347498ae4e2706805c1ff-1" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/#rest_code_21f35023835347498ae4e2706805c1ff-1"&gt;&lt;/a&gt;Nov 18 06:45:25 yankee postfix/smtpd[25869]: warning: connect to Milter
&lt;a id="rest_code_21f35023835347498ae4e2706805c1ff-2" name="rest_code_21f35023835347498ae4e2706805c1ff-2" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/#rest_code_21f35023835347498ae4e2706805c1ff-2"&gt;&lt;/a&gt;service inet:localhost:8891: Connection refused
&lt;a id="rest_code_21f35023835347498ae4e2706805c1ff-3" name="rest_code_21f35023835347498ae4e2706805c1ff-3" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/#rest_code_21f35023835347498ae4e2706805c1ff-3"&gt;&lt;/a&gt;Nov 18 06:45:25 yankee postfix/smtpd[25869]: NOQUEUE: milter-reject: CONNECT
&lt;a id="rest_code_21f35023835347498ae4e2706805c1ff-4" name="rest_code_21f35023835347498ae4e2706805c1ff-4" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/#rest_code_21f35023835347498ae4e2706805c1ff-4"&gt;&lt;/a&gt;from unknown[2a01:d0:801a:1::12]: 451 4.7.1 Service unavailable - try again
&lt;a id="rest_code_21f35023835347498ae4e2706805c1ff-5" name="rest_code_21f35023835347498ae4e2706805c1ff-5" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/#rest_code_21f35023835347498ae4e2706805c1ff-5"&gt;&lt;/a&gt;later; proto=SMTP
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;What happened is I got a new opendkim package (2.6.8-0ubuntu1~ubuntu10.04.1)
which listens on a unix domain socket by default, and not inet interface which
I had configured for the filters.&lt;/p&gt;
&lt;p&gt;The fix was to update &lt;code class="docutils literal"&gt;/etc/opendkim.conf&lt;/code&gt; and add this:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_be473857720c4c8a96e433fbf58790ba-1" name="rest_code_be473857720c4c8a96e433fbf58790ba-1" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/#rest_code_be473857720c4c8a96e433fbf58790ba-1"&gt;&lt;/a&gt;Socket          inet:8891@localhost
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Alternatively, this can be configured in &lt;code class="docutils literal"&gt;/etc/default/opendkim&lt;/code&gt;:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_5940937e3710494ab838ce31ef8fbd5f-1" name="rest_code_5940937e3710494ab838ce31ef8fbd5f-1" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/#rest_code_5940937e3710494ab838ce31ef8fbd5f-1"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# Uncomment to specify an alternate socket&lt;/span&gt;
&lt;a id="rest_code_5940937e3710494ab838ce31ef8fbd5f-2" name="rest_code_5940937e3710494ab838ce31ef8fbd5f-2" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/#rest_code_5940937e3710494ab838ce31ef8fbd5f-2"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# Note that setting this will override any Socket value in opendkim.conf&lt;/span&gt;
&lt;a id="rest_code_5940937e3710494ab838ce31ef8fbd5f-3" name="rest_code_5940937e3710494ab838ce31ef8fbd5f-3" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/#rest_code_5940937e3710494ab838ce31ef8fbd5f-3"&gt;&lt;/a&gt;&lt;span class="c1"&gt;#SOCKET="local:/var/run/opendkim/opendkim.sock" # default&lt;/span&gt;
&lt;a id="rest_code_5940937e3710494ab838ce31ef8fbd5f-4" name="rest_code_5940937e3710494ab838ce31ef8fbd5f-4" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/#rest_code_5940937e3710494ab838ce31ef8fbd5f-4"&gt;&lt;/a&gt;&lt;span class="c1"&gt;#SOCKET="inet:54321" # listen on all interfaces on port 54321&lt;/span&gt;
&lt;a id="rest_code_5940937e3710494ab838ce31ef8fbd5f-5" name="rest_code_5940937e3710494ab838ce31ef8fbd5f-5" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/#rest_code_5940937e3710494ab838ce31ef8fbd5f-5"&gt;&lt;/a&gt;&lt;span class="c1"&gt;#SOCKET="inet:12345@localhost" # listen on loopback on port 12345&lt;/span&gt;
&lt;a id="rest_code_5940937e3710494ab838ce31ef8fbd5f-6" name="rest_code_5940937e3710494ab838ce31ef8fbd5f-6" href="https://www.keypressure.com/blog/opendkim-update-in-lucid/#rest_code_5940937e3710494ab838ce31ef8fbd5f-6"&gt;&lt;/a&gt;&lt;span class="c1"&gt;#SOCKET="inet:12345@192.0.2.1" # listen on 192.0.2.1 on port 12345&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This took a while since I could not recall how I configured opendkim to listen
to tcp socket in the first place. At least now it is obvious.&lt;/p&gt;</description><category>email</category><category>en</category><category>fix</category><category>lucid</category><category>opendkim</category><category>postfix</category><category>ubuntu</category><guid>https://www.keypressure.com/blog/opendkim-update-in-lucid/</guid><pubDate>Thu, 22 Nov 2012 03:44:00 GMT</pubDate></item><item><title>Securing wordpress admin with SSL – The hard way</title><link>https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/</link><dc:creator>Roman Yepishev</dc:creator><description>&lt;p class="alert"&gt;I have since moved away from WordPress back to a static generator, so
everything below can be considered an outdated information.&lt;/p&gt;
&lt;p&gt;Having performed initial migration from Octopress to a hosted WordPress
installation I found that I became in charge of login security. The hosting
provider I am currently using provides neither dedicated IP addresses nor
shared SSL certificates (update: it does provide a dedicated IP address upon request, but requires a
support ticket and a small fee for that) it means that my WordPress password
and session information is transmitted in clear text. Of course, when I am at
home it’s not a big deal, only the ISP may intercept it. But when I am
anywhere else, my devices can connect to some unprotected Wi-Fi access point
and accidentally surrender my credentials to somebody running tcpdump nearby…&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="/galleries/dropbox/wordpress-tcpdump-624x160.jpg" src="https://www.keypressure.com/galleries/dropbox/wordpress-tcpdump-624x160.jpg"&gt;
&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Since I found out that the hosting provider actually provides a
dedicated IP upon request for a quite small fee (25₴ at the moment, around
$3), the value of the article has decreased. However, it is perfectly usable
when nginx and wordpress are installed on the same host/datacenter but nginx
is fronting apache.&lt;/p&gt;
&lt;hr class="docutils"&gt;
&lt;p&gt;I have a VPS which is used for occasional VPN access (using &lt;a class="reference external" href="http://openvpn.net/"&gt;OpenVPN&lt;/a&gt;). One
option was to always start OpenVPN client before accessing the blog. I could
easily forget to do that. My browser may open the tab where I am already
logged in and then my session cookie can be &lt;a class="reference external" href="https://wordpress.org/support/topic/securing-loginphp-with-ssl#post-154136"&gt;easily intercepted&lt;/a&gt;. Also I can’t
use this VPS for WordPress hosting itself because it has only 512Mb of RAM and
bringing up a SQL server, HTTP server (as well as keeping existing mail server
setup, bip and OpenVPN running) may cause something to fall outside the
available memory. Having said that, it looks like it is possible to run a
WordPress blog in a similar configuration with whopping &lt;a class="reference external" href="http://www.ewanleith.com/blog/900/10-million-hits-a-day-with-wordpress-using-a-15-server"&gt;10 million hits a day&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I decided to make this VPS act as a proxy server, which listens to HTTP and
HTTPS traffic and forwards the requests to the hosting provider. In this case
everything will pass through the VPS.&lt;/p&gt;
&lt;p&gt;WordPress already has the options to &lt;a class="reference external" href="http://codex.wordpress.org/Administration_Over_SSL"&gt;force https scheme on wp-login.php and
wp-admin&lt;/a&gt; directory.&lt;/p&gt;
&lt;p&gt;Since this VPS is a low-profile one, a slim HTTP server is required. While I
am already familiar with &lt;a class="reference external" href="http://www.lighttpd.net/"&gt;Lighttpd&lt;/a&gt;, I decided to try &lt;a class="reference external" href="http://wiki.nginx.org/Main"&gt;nginx&lt;/a&gt;.&lt;/p&gt;
&lt;img alt="/galleries/dropbox/startssl-no-kidding.png" class="pull-left" src="https://www.keypressure.com/galleries/dropbox/startssl-no-kidding.png"&gt;
&lt;p&gt;You will need a SSL certificate. &lt;a class="reference external" href="https://www.startssl.com/"&gt;StartSSL&lt;/a&gt; is a
good place to get one for free and it is recognized by major browsers out of
the box. Approving new accounts takes time so I decided to use the old proven
&lt;a class="reference external" href="http://www.akadia.com/services/ssh_test_certificate.html"&gt;self signed certificate&lt;/a&gt; first and then change it to a proper one.&lt;/p&gt;
&lt;p class="alert alert-info"&gt;Here I would like to remind how important StartSSL &lt;em&gt;client&lt;/em&gt; certificate is. You
get the client certificate upon account approval and then use it to log into
StartSSL control panel. This certificate will eventually expire and if you
fail to renew it, you will never be able to get back to your account. Don’t
repeat my mistake – when StartSSL tells you the certificate is about to
expire, then get a new one &lt;strong&gt;immediately&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The VPS is running Ubuntu 10.04 LTS and (naturally) nginx version is quite old
(0.7.65, February 2010). Nginx team has a &lt;a class="reference external" href="https://launchpad.net/~nginx/+archive/stable"&gt;PPA&lt;/a&gt; that builds packages for 10.04
too, so installation was simple:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_5c0a24e9ac6843fbaf48f7d3a734e775-1" name="rest_code_5c0a24e9ac6843fbaf48f7d3a734e775-1" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_5c0a24e9ac6843fbaf48f7d3a734e775-1"&gt;&lt;/a&gt;sudo apt-add-repository ppa:nginx/stable
&lt;a id="rest_code_5c0a24e9ac6843fbaf48f7d3a734e775-2" name="rest_code_5c0a24e9ac6843fbaf48f7d3a734e775-2" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_5c0a24e9ac6843fbaf48f7d3a734e775-2"&gt;&lt;/a&gt;sudo apt-get update
&lt;a id="rest_code_5c0a24e9ac6843fbaf48f7d3a734e775-3" name="rest_code_5c0a24e9ac6843fbaf48f7d3a734e775-3" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_5c0a24e9ac6843fbaf48f7d3a734e775-3"&gt;&lt;/a&gt;sudo apt-get install nginx
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Nginx comes with a &lt;a class="reference external" href="http://wiki.nginx.org/HttpProxyModule#proxy_cache"&gt;proxy cache&lt;/a&gt; module. At first I started with a simple
configuration that cached everything, then I found that the pages that were
rendered for some commenter were also served to other people disclosing the
previous commenter’s email. This is why preventing serving the cached content
to the owners of our cookies is so important.&lt;/p&gt;
&lt;p&gt;nic.ua also uses nginx as a proxy in front of apache. Therefore it is
overwriting the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;X-Real-IP&lt;/span&gt;&lt;/code&gt; header which my proxy is setting. In order to work
around that I used &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;X-Upstream-Real-IP&lt;/span&gt;&lt;/code&gt; header, which I use in &lt;code class="docutils literal"&gt;.htaccess&lt;/code&gt; to set
&lt;code class="docutils literal"&gt;UPSTREAM_PROXY_TRUSTED&lt;/code&gt; variable. The latter is then checked in &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;wp-config.php&lt;/span&gt;&lt;/code&gt;
to decide whether &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;X-Forwarded-Proto&lt;/span&gt;&lt;/code&gt; and &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;X-Upstream-Real-IP&lt;/span&gt;&lt;/code&gt; headers can be
trusted. These X- headers can easily be forged and &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;X-Forwarded-Proto&lt;/span&gt;&lt;/code&gt; should
only be used if it comes from the trusted sources, or else the &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Man-in-the-middle_attack"&gt;MITM&lt;/a&gt; attacks
become extremely easy.&lt;/p&gt;
&lt;p&gt;/etc/nginx/sites-available/rtg.in.ua:&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.keypressure.com/listings/sites-available-rtg-in-ua.apache.html"&gt;sites-available-rtg-in-ua.apache&lt;/a&gt;  &lt;a class="reference external" href="https://www.keypressure.com/listings/sites-available-rtg-in-ua.apache"&gt;(Source)&lt;/a&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code apache"&gt;&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-1" name="rest_code_4850efacdb3d42c18438c0899b372c86-1" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-1"&gt;&lt;/a&gt;&lt;span class="nb"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-2" name="rest_code_4850efacdb3d42c18438c0899b372c86-2" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;listen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;[::]:80;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-3" name="rest_code_4850efacdb3d42c18438c0899b372c86-3" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;server_name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;www.rtg.in.ua&lt;span class="w"&gt; &lt;/span&gt;blog.rtg.in.ua;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-4" name="rest_code_4850efacdb3d42c18438c0899b372c86-4" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;rewrite&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;^&lt;span class="w"&gt; &lt;/span&gt;http://rtg.in.ua$request_uri?&lt;span class="w"&gt; &lt;/span&gt;permanent;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-5" name="rest_code_4850efacdb3d42c18438c0899b372c86-5" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-5"&gt;&lt;/a&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-6" name="rest_code_4850efacdb3d42c18438c0899b372c86-6" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-6"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-7" name="rest_code_4850efacdb3d42c18438c0899b372c86-7" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-7"&gt;&lt;/a&gt;&lt;span class="nb"&gt;upstream&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;wordpress&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-8" name="rest_code_4850efacdb3d42c18438c0899b372c86-8" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;91.209.206.62&lt;/span&gt;:80;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-9" name="rest_code_4850efacdb3d42c18438c0899b372c86-9" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-9"&gt;&lt;/a&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-10" name="rest_code_4850efacdb3d42c18438c0899b372c86-10" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-10"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-11" name="rest_code_4850efacdb3d42c18438c0899b372c86-11" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-11"&gt;&lt;/a&gt;&lt;span class="nb"&gt;proxy_cache&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;cache;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-12" name="rest_code_4850efacdb3d42c18438c0899b372c86-12" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-12"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-13" name="rest_code_4850efacdb3d42c18438c0899b372c86-13" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-13"&gt;&lt;/a&gt;&lt;span class="nb"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-14" name="rest_code_4850efacdb3d42c18438c0899b372c86-14" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-14"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;proxy_params;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-15" name="rest_code_4850efacdb3d42c18438c0899b372c86-15" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-15"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-16" name="rest_code_4850efacdb3d42c18438c0899b372c86-16" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-16"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c"&gt;# sites-available/default should also have listen directive changed&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-17" name="rest_code_4850efacdb3d42c18438c0899b372c86-17" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-17"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c"&gt;# for IPv6 &amp;amp; IPv4 to work to &lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-18" name="rest_code_4850efacdb3d42c18438c0899b372c86-18" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-18"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c"&gt;#   listen   [::]:80 default_server;&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-19" name="rest_code_4850efacdb3d42c18438c0899b372c86-19" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-19"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;listen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;[::]:80;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-20" name="rest_code_4850efacdb3d42c18438c0899b372c86-20" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-20"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;server_name&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;rtg.in.ua;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-21" name="rest_code_4850efacdb3d42c18438c0899b372c86-21" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-21"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-22" name="rest_code_4850efacdb3d42c18438c0899b372c86-22" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-22"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;access_log&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="sx"&gt;/var/log/nginx/rtg-in-ua.access.log&lt;/span&gt;;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-23" name="rest_code_4850efacdb3d42c18438c0899b372c86-23" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-23"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-24" name="rest_code_4850efacdb3d42c18438c0899b372c86-24" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-24"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;/&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-25" name="rest_code_4850efacdb3d42c18438c0899b372c86-25" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-25"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_pass&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;http://wordpress;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-26" name="rest_code_4850efacdb3d42c18438c0899b372c86-26" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-26"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_cache_valid&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;404&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;m;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-27" name="rest_code_4850efacdb3d42c18438c0899b372c86-27" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-27"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-28" name="rest_code_4850efacdb3d42c18438c0899b372c86-28" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-28"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c"&gt;# we should not serve cached version if we have one of these cookies&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-29" name="rest_code_4850efacdb3d42c18438c0899b372c86-29" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-29"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;($http_cookie&lt;span class="w"&gt; &lt;/span&gt;~*&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wordpress|comment_author|wp-postpass_"&lt;/span&gt;)&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-30" name="rest_code_4850efacdb3d42c18438c0899b372c86-30" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-30"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;$bypass_cache&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-31" name="rest_code_4850efacdb3d42c18438c0899b372c86-31" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-31"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-32" name="rest_code_4850efacdb3d42c18438c0899b372c86-32" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-32"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-33" name="rest_code_4850efacdb3d42c18438c0899b372c86-33" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-33"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_cache_bypass&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;$bypass_cache;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-34" name="rest_code_4850efacdb3d42c18438c0899b372c86-34" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-34"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-35" name="rest_code_4850efacdb3d42c18438c0899b372c86-35" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-35"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-36" name="rest_code_4850efacdb3d42c18438c0899b372c86-36" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-36"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c"&gt;# These are completely static and can be shared between&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-37" name="rest_code_4850efacdb3d42c18438c0899b372c86-37" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-37"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c"&gt;# HTTP and HTTPS virtual hosts&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-38" name="rest_code_4850efacdb3d42c18438c0899b372c86-38" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-38"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;~*&lt;span class="w"&gt; &lt;/span&gt;\.(jpg|jpeg|png|gif|css|js|mp3|wav|swf|ogg|txt)&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-39" name="rest_code_4850efacdb3d42c18438c0899b372c86-39" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-39"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_cache_key&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;$host$request_uri;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-40" name="rest_code_4850efacdb3d42c18438c0899b372c86-40" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-40"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_cache_valid&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;120&lt;/span&gt;m;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-41" name="rest_code_4850efacdb3d42c18438c0899b372c86-41" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-41"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c"&gt;# 30 days&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-42" name="rest_code_4850efacdb3d42c18438c0899b372c86-42" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-42"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;expires&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2592000&lt;/span&gt;;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-43" name="rest_code_4850efacdb3d42c18438c0899b372c86-43" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-43"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_pass&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;http://wordpress;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-44" name="rest_code_4850efacdb3d42c18438c0899b372c86-44" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-44"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-45" name="rest_code_4850efacdb3d42c18438c0899b372c86-45" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-45"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-46" name="rest_code_4850efacdb3d42c18438c0899b372c86-46" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-46"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;~*&lt;span class="w"&gt; &lt;/span&gt;(^|\/)feed\/&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-47" name="rest_code_4850efacdb3d42c18438c0899b372c86-47" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-47"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_cache_valid&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;60&lt;/span&gt;m;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-48" name="rest_code_4850efacdb3d42c18438c0899b372c86-48" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-48"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_pass&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;http://wordpress;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-49" name="rest_code_4850efacdb3d42c18438c0899b372c86-49" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-49"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-50" name="rest_code_4850efacdb3d42c18438c0899b372c86-50" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-50"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-51" name="rest_code_4850efacdb3d42c18438c0899b372c86-51" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-51"&gt;&lt;/a&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-52" name="rest_code_4850efacdb3d42c18438c0899b372c86-52" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-52"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-53" name="rest_code_4850efacdb3d42c18438c0899b372c86-53" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-53"&gt;&lt;/a&gt;&lt;span class="c"&gt;# HTTPS server&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-54" name="rest_code_4850efacdb3d42c18438c0899b372c86-54" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-54"&gt;&lt;/a&gt;&lt;span class="c"&gt;# We allow all interaction to happen over HTTPS too.&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-55" name="rest_code_4850efacdb3d42c18438c0899b372c86-55" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-55"&gt;&lt;/a&gt;&lt;span class="nb"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-56" name="rest_code_4850efacdb3d42c18438c0899b372c86-56" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-56"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;listen&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;[::]:443;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-57" name="rest_code_4850efacdb3d42c18438c0899b372c86-57" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-57"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;server_name&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;rtg.in.ua;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-58" name="rest_code_4850efacdb3d42c18438c0899b372c86-58" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-58"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;proxy_params;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-59" name="rest_code_4850efacdb3d42c18438c0899b372c86-59" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-59"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-60" name="rest_code_4850efacdb3d42c18438c0899b372c86-60" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-60"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;ssl&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="k"&gt;on&lt;/span&gt;;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-61" name="rest_code_4850efacdb3d42c18438c0899b372c86-61" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-61"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;ssl_certificate&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="sx"&gt;/etc/ssl/certs/rtg-in-ua.crt&lt;/span&gt;;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-62" name="rest_code_4850efacdb3d42c18438c0899b372c86-62" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-62"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;ssl_certificate_key&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="sx"&gt;/etc/ssl/private/server.key&lt;/span&gt;;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-63" name="rest_code_4850efacdb3d42c18438c0899b372c86-63" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-63"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-64" name="rest_code_4850efacdb3d42c18438c0899b372c86-64" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-64"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;ssl_session_timeout&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;m;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-65" name="rest_code_4850efacdb3d42c18438c0899b372c86-65" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-65"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-66" name="rest_code_4850efacdb3d42c18438c0899b372c86-66" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-66"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;ssl_protocols&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;SSLv2&lt;span class="w"&gt; &lt;/span&gt;SSLv3&lt;span class="w"&gt; &lt;/span&gt;TLSv1;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-67" name="rest_code_4850efacdb3d42c18438c0899b372c86-67" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-67"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;ssl_ciphers&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="k"&gt;ALL&lt;/span&gt;:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-68" name="rest_code_4850efacdb3d42c18438c0899b372c86-68" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-68"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;ssl_prefer_server_ciphers&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="k"&gt;on&lt;/span&gt;;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-69" name="rest_code_4850efacdb3d42c18438c0899b372c86-69" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-69"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-70" name="rest_code_4850efacdb3d42c18438c0899b372c86-70" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-70"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;access_log&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="sx"&gt;/var/log/nginx/rtg-in-ua.access.log&lt;/span&gt;;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-71" name="rest_code_4850efacdb3d42c18438c0899b372c86-71" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-71"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-72" name="rest_code_4850efacdb3d42c18438c0899b372c86-72" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-72"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;/&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-73" name="rest_code_4850efacdb3d42c18438c0899b372c86-73" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-73"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_cache&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;cache;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-74" name="rest_code_4850efacdb3d42c18438c0899b372c86-74" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-74"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_cache_valid&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;404&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;m;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-75" name="rest_code_4850efacdb3d42c18438c0899b372c86-75" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-75"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-76" name="rest_code_4850efacdb3d42c18438c0899b372c86-76" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-76"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;($http_cookie&lt;span class="w"&gt; &lt;/span&gt;~*&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wordpress|comment_author|wp-postpass_"&lt;/span&gt;)&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-77" name="rest_code_4850efacdb3d42c18438c0899b372c86-77" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-77"&gt;&lt;/a&gt;&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;$bypass_cache&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-78" name="rest_code_4850efacdb3d42c18438c0899b372c86-78" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-78"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-79" name="rest_code_4850efacdb3d42c18438c0899b372c86-79" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-79"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-80" name="rest_code_4850efacdb3d42c18438c0899b372c86-80" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-80"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_cache_bypass&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;$bypass_cache;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-81" name="rest_code_4850efacdb3d42c18438c0899b372c86-81" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-81"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_pass&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;http://wordpress;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-82" name="rest_code_4850efacdb3d42c18438c0899b372c86-82" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-82"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-83" name="rest_code_4850efacdb3d42c18438c0899b372c86-83" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-83"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-84" name="rest_code_4850efacdb3d42c18438c0899b372c86-84" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-84"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;~*&lt;span class="w"&gt; &lt;/span&gt;^(wp-admin|wp-login)&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-85" name="rest_code_4850efacdb3d42c18438c0899b372c86-85" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-85"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_pass&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;http://wordpress;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-86" name="rest_code_4850efacdb3d42c18438c0899b372c86-86" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-86"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-87" name="rest_code_4850efacdb3d42c18438c0899b372c86-87" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-87"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-88" name="rest_code_4850efacdb3d42c18438c0899b372c86-88" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-88"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;~*&lt;span class="w"&gt; &lt;/span&gt;\.(jpg|jpeg|png|gif|css|js|mp3|wav|swf|ogg|txt)&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-89" name="rest_code_4850efacdb3d42c18438c0899b372c86-89" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-89"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_cache_key&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;$host$request_uri;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-90" name="rest_code_4850efacdb3d42c18438c0899b372c86-90" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-90"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_cache_valid&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;120&lt;/span&gt;m;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-91" name="rest_code_4850efacdb3d42c18438c0899b372c86-91" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-91"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;expires&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2592000&lt;/span&gt;;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-92" name="rest_code_4850efacdb3d42c18438c0899b372c86-92" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-92"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_pass&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;http://wordpress;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-93" name="rest_code_4850efacdb3d42c18438c0899b372c86-93" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-93"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-94" name="rest_code_4850efacdb3d42c18438c0899b372c86-94" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-94"&gt;&lt;/a&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-95" name="rest_code_4850efacdb3d42c18438c0899b372c86-95" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-95"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;~*&lt;span class="w"&gt; &lt;/span&gt;(^|\/)feed\/&lt;span class="w"&gt; &lt;/span&gt;{
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-96" name="rest_code_4850efacdb3d42c18438c0899b372c86-96" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-96"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_cache_valid&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;60&lt;/span&gt;m;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-97" name="rest_code_4850efacdb3d42c18438c0899b372c86-97" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-97"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_cache&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;cache;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-98" name="rest_code_4850efacdb3d42c18438c0899b372c86-98" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-98"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;proxy_pass&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;http://wordpress;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-99" name="rest_code_4850efacdb3d42c18438c0899b372c86-99" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-99"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;a id="rest_code_4850efacdb3d42c18438c0899b372c86-100" name="rest_code_4850efacdb3d42c18438c0899b372c86-100" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_4850efacdb3d42c18438c0899b372c86-100"&gt;&lt;/a&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;/etc/nginx/conf.d/proxy-cache.conf:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_7c03d08cf0594a3ca1af977e3dafe568-1" name="rest_code_7c03d08cf0594a3ca1af977e3dafe568-1" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_7c03d08cf0594a3ca1af977e3dafe568-1"&gt;&lt;/a&gt;proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache:30m max_size=1G;
&lt;a id="rest_code_7c03d08cf0594a3ca1af977e3dafe568-2" name="rest_code_7c03d08cf0594a3ca1af977e3dafe568-2" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_7c03d08cf0594a3ca1af977e3dafe568-2"&gt;&lt;/a&gt;proxy_temp_path /var/lib/nginx/proxy 1 2;
&lt;a id="rest_code_7c03d08cf0594a3ca1af977e3dafe568-3" name="rest_code_7c03d08cf0594a3ca1af977e3dafe568-3" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_7c03d08cf0594a3ca1af977e3dafe568-3"&gt;&lt;/a&gt;proxy_cache_key $scheme$host$request_uri;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;/etc/nginx/proxy_params:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_5be7ab3b96f744a287602450517ef0dc-1" name="rest_code_5be7ab3b96f744a287602450517ef0dc-1" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_5be7ab3b96f744a287602450517ef0dc-1"&gt;&lt;/a&gt;proxy_set_header Host $host;
&lt;a id="rest_code_5be7ab3b96f744a287602450517ef0dc-2" name="rest_code_5be7ab3b96f744a287602450517ef0dc-2" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_5be7ab3b96f744a287602450517ef0dc-2"&gt;&lt;/a&gt;# This gets overwritten:
&lt;a id="rest_code_5be7ab3b96f744a287602450517ef0dc-3" name="rest_code_5be7ab3b96f744a287602450517ef0dc-3" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_5be7ab3b96f744a287602450517ef0dc-3"&gt;&lt;/a&gt;proxy_set_header X-Real-IP $remote_addr;
&lt;a id="rest_code_5be7ab3b96f744a287602450517ef0dc-4" name="rest_code_5be7ab3b96f744a287602450517ef0dc-4" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_5be7ab3b96f744a287602450517ef0dc-4"&gt;&lt;/a&gt;# This is our own header:
&lt;a id="rest_code_5be7ab3b96f744a287602450517ef0dc-5" name="rest_code_5be7ab3b96f744a287602450517ef0dc-5" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_5be7ab3b96f744a287602450517ef0dc-5"&gt;&lt;/a&gt;proxy_set_header X-Upstream-Real-IP $remote_addr;
&lt;a id="rest_code_5be7ab3b96f744a287602450517ef0dc-6" name="rest_code_5be7ab3b96f744a287602450517ef0dc-6" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_5be7ab3b96f744a287602450517ef0dc-6"&gt;&lt;/a&gt;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
&lt;a id="rest_code_5be7ab3b96f744a287602450517ef0dc-7" name="rest_code_5be7ab3b96f744a287602450517ef0dc-7" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_5be7ab3b96f744a287602450517ef0dc-7"&gt;&lt;/a&gt;proxy_set_header X-Forwarded-Proto $scheme;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;While it looks like I am just re-setting &lt;code class="docutils literal"&gt;proxy_cache_key&lt;/code&gt; to the default value,
nginx is actually using &lt;a class="reference external" href="http://forum.nginx.org/read.php?2,160984,160989#msg-160989"&gt;backend URL by default&lt;/a&gt; (contrary to the &lt;a class="reference external" href="http://wiki.nginx.org/HttpProxyModule#proxy_cache_key"&gt;docs&lt;/a&gt;!), thus
you will be serving a document full of generated HTTP links on a HTTPS
connection and vice versa.&lt;/p&gt;
&lt;p&gt;I decided to create a new directory for the cache:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_593cf7682d9e4a42a672d3839e429e95-1" name="rest_code_593cf7682d9e4a42a672d3839e429e95-1" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_593cf7682d9e4a42a672d3839e429e95-1"&gt;&lt;/a&gt;sudo mkdir -m 0700 /var/cache/nginx
&lt;a id="rest_code_593cf7682d9e4a42a672d3839e429e95-2" name="rest_code_593cf7682d9e4a42a672d3839e429e95-2" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_593cf7682d9e4a42a672d3839e429e95-2"&gt;&lt;/a&gt;sudo chown www-data:root /var/cache/nginx
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Enabled the virtual host and restarted the server:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_ae9ae67c6e044bb6a230b3c5fd53de2b-1" name="rest_code_ae9ae67c6e044bb6a230b3c5fd53de2b-1" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_ae9ae67c6e044bb6a230b3c5fd53de2b-1"&gt;&lt;/a&gt;sudo ln -s /etc/nginx/sites-available/rtg.in.ua /etc/nginx/sites-enabled
&lt;a id="rest_code_ae9ae67c6e044bb6a230b3c5fd53de2b-2" name="rest_code_ae9ae67c6e044bb6a230b3c5fd53de2b-2" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_ae9ae67c6e044bb6a230b3c5fd53de2b-2"&gt;&lt;/a&gt;sudo /etc/init.d/nginx restart
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Nginx is configured, the proxy server is ready to serve.&lt;/p&gt;
&lt;p&gt;Now back to the WordPress installation, setting the &lt;code class="docutils literal"&gt;UPSTREAM_PROXY_TRUSTED&lt;/code&gt;
variable:&lt;/p&gt;
&lt;p&gt;.htaccess:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code apache"&gt;&lt;a id="rest_code_8cb971bb7da34bdfa61f2ac166718e9c-1" name="rest_code_8cb971bb7da34bdfa61f2ac166718e9c-1" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_8cb971bb7da34bdfa61f2ac166718e9c-1"&gt;&lt;/a&gt;&lt;span class="c"&gt;# Trusted IPs&lt;/span&gt;
&lt;a id="rest_code_8cb971bb7da34bdfa61f2ac166718e9c-2" name="rest_code_8cb971bb7da34bdfa61f2ac166718e9c-2" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_8cb971bb7da34bdfa61f2ac166718e9c-2"&gt;&lt;/a&gt;&lt;span class="nb"&gt;RewriteCond&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;%{REMOTE_ADDR}&lt;span class="w"&gt; &lt;/span&gt;=173.212.238.58&lt;span class="w"&gt; &lt;/span&gt;[OR]
&lt;a id="rest_code_8cb971bb7da34bdfa61f2ac166718e9c-3" name="rest_code_8cb971bb7da34bdfa61f2ac166718e9c-3" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_8cb971bb7da34bdfa61f2ac166718e9c-3"&gt;&lt;/a&gt;&lt;span class="nb"&gt;RewriteCond&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;%{REMOTE_ADDR}&lt;span class="w"&gt; &lt;/span&gt;=2607:f878:1:654:0:25:3078:1&lt;span class="w"&gt; &lt;/span&gt;[OR]
&lt;a id="rest_code_8cb971bb7da34bdfa61f2ac166718e9c-4" name="rest_code_8cb971bb7da34bdfa61f2ac166718e9c-4" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_8cb971bb7da34bdfa61f2ac166718e9c-4"&gt;&lt;/a&gt;&lt;span class="nb"&gt;RewriteCond&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;%{REMOTE_ADDR}&lt;span class="w"&gt; &lt;/span&gt;=178.159.236.29&lt;span class="w"&gt; &lt;/span&gt;[OR]
&lt;a id="rest_code_8cb971bb7da34bdfa61f2ac166718e9c-5" name="rest_code_8cb971bb7da34bdfa61f2ac166718e9c-5" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_8cb971bb7da34bdfa61f2ac166718e9c-5"&gt;&lt;/a&gt;&lt;span class="nb"&gt;RewriteCond&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;%{REMOTE_ADDR}&lt;span class="w"&gt; &lt;/span&gt;=2a01:d0:801a:1::14
&lt;a id="rest_code_8cb971bb7da34bdfa61f2ac166718e9c-6" name="rest_code_8cb971bb7da34bdfa61f2ac166718e9c-6" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_8cb971bb7da34bdfa61f2ac166718e9c-6"&gt;&lt;/a&gt;&lt;span class="nb"&gt;RewriteRule&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;.&lt;span class="w"&gt; &lt;/span&gt;-&lt;span class="w"&gt; &lt;/span&gt;[E=UPSTREAM_PROXY_TRUSTED:1]
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And now we need WordPress to redirect all the login and admin activities to
https:// urls as well as trust &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;X-Forwarded-Proto&lt;/span&gt;&lt;/code&gt; HTTP header by adding the
following to &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;wp-config.php&lt;/span&gt;&lt;/code&gt;:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code php"&gt;&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-1" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-1" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-1"&gt;&lt;/a&gt;&lt;span class="x"&gt;...&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-2" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-2" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-2"&gt;&lt;/a&gt;&lt;span class="x"&gt;/*&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-3" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-3" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-3"&gt;&lt;/a&gt;&lt;span class="x"&gt;* http://codex.wordpress.org/Administration_Over_SSL&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-4" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-4" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-4"&gt;&lt;/a&gt;&lt;span class="x"&gt;*/&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-5" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-5" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-5"&gt;&lt;/a&gt;&lt;span class="x"&gt;define('FORCE_SSL_ADMIN', true);&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-6" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-6" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-6"&gt;&lt;/a&gt;&lt;span class="x"&gt;define('FORCE_SSL_LOGIN', true);&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-7" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-7" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-8" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-8" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-8"&gt;&lt;/a&gt;&lt;span class="x"&gt;/*&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-9" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-9" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-9"&gt;&lt;/a&gt;&lt;span class="x"&gt;* This variable is set in .htaccess in case&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-10" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-10" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-10"&gt;&lt;/a&gt;&lt;span class="x"&gt;* REMOTE_ADDR is one of our upstream proxies&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-11" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-11" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-11"&gt;&lt;/a&gt;&lt;span class="x"&gt;*/&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-12" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-12" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-12"&gt;&lt;/a&gt;&lt;span class="x"&gt;if ($_ENV['UPSTREAM_PROXY_TRUSTED']) {&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-13" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-13" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-13"&gt;&lt;/a&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-14" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-14" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-14"&gt;&lt;/a&gt;&lt;span class="x"&gt;    if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-15" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-15" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-15"&gt;&lt;/a&gt;&lt;span class="x"&gt;    $_SERVER['HTTPS']='on';&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-16" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-16" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-16"&gt;&lt;/a&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-17" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-17" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-17"&gt;&lt;/a&gt;&lt;span class="x"&gt;    /*&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-18" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-18" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-18"&gt;&lt;/a&gt;&lt;span class="x"&gt;    * X-Real-IP is overwritten by nginx proxy @ nic.ua&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-19" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-19" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-19"&gt;&lt;/a&gt;&lt;span class="x"&gt;    * so we are using our own header.&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-20" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-20" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-20"&gt;&lt;/a&gt;&lt;span class="x"&gt;    */&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-21" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-21" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-21"&gt;&lt;/a&gt;&lt;span class="x"&gt;    $x_real_ip = $_SERVER['HTTP_X_UPSTREAM_REAL_IP'];&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-22" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-22" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-22"&gt;&lt;/a&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-23" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-23" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-23"&gt;&lt;/a&gt;&lt;span class="x"&gt;    // IPv4 in IPv6 notation&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-24" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-24" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-24"&gt;&lt;/a&gt;&lt;span class="x"&gt;    if (substr($x_real_ip, 0, 7) == "::ffff:")&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-25" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-25" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-25"&gt;&lt;/a&gt;&lt;span class="x"&gt;        $x_real_ip = substr($x_real_ip, 7);&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-26" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-26" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-26"&gt;&lt;/a&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-27" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-27" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-27"&gt;&lt;/a&gt;&lt;span class="x"&gt;    $_SERVER['REMOTE_ADDR'] = $x_real_ip;&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-28" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-28" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-28"&gt;&lt;/a&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-29" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-29" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-29"&gt;&lt;/a&gt;&lt;span class="x"&gt;}&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-30" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-30" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-30"&gt;&lt;/a&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-31" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-31" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-31"&gt;&lt;/a&gt;&lt;span class="x"&gt;/* That's all, stop editing! Happy blogging. */&lt;/span&gt;
&lt;a id="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-32" name="rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-32" href="https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/#rest_code_fb9fbf8754cb4b8da0c10a8ae06bb1fa-32"&gt;&lt;/a&gt;&lt;span class="x"&gt;...&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That’s pretty much it. Self-signed, but encrypted:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="/galleries/dropbox/wp-login-https-cropped.png" src="https://www.keypressure.com/galleries/dropbox/wp-login-https-cropped.png"&gt;
&lt;figcaption&gt;
&lt;p&gt;Chromium SSL popup&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;This approach has several flaws. First of all, I am increasing the number of
points of failure. Since the data has to travel from Ukraine to the US even
when request comes from Ukraine, the latency is increased a bit. CDN usage also
gets more complicated (unless static files are served on a different domain).
Neither of these issues is currently bothering as I am still in the process of
migrating my content.&lt;/p&gt;
&lt;p&gt;Please note that I am not a nginx guru, so if you see any error in the
configuration, let me know.&lt;/p&gt;</description><category>en</category><category>linux</category><category>nginx</category><category>php</category><category>proxy</category><category>security</category><category>ssl</category><category>startssl</category><category>the-hard-way</category><category>ubuntu</category><category>wordpress</category><guid>https://www.keypressure.com/blog/wordpress-admin-ssl-hard-way/</guid><pubDate>Tue, 20 Nov 2012 10:31:00 GMT</pubDate></item></channel></rss>