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

<channel>
	<title>Personal blog of Chris Ergatides &#187; apache</title>
	<atom:link href="http://blog.ergatides.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ergatides.com</link>
	<description>jQuery, Linux, Technology, Web Design and random stuff.</description>
	<lastBuildDate>Mon, 06 Feb 2012 05:01:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Using sed to search and replace contents of next line in a file.</title>
		<link>http://blog.ergatides.com/2012/01/24/using-sed-to-search-and-replace-contents-of-next-line-in-a-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-sed-to-search-and-replace-contents-of-next-line-in-a-file</link>
		<comments>http://blog.ergatides.com/2012/01/24/using-sed-to-search-and-replace-contents-of-next-line-in-a-file/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 13:50:19 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[dyndns]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[no-ip]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://blog.ergatides.com/?p=1740</guid>


		<description><![CDATA[<p>This example will show you how easy it is using sed to find a particular line in a file and replace all or part of the next line. In this example, using htaccess we want to deny access to all clients except a particular dynamic IP (for your home connection for instance).</p>
<p>Your .htaccess file might look like this:</p>
<pre class="brush: plain; title: ; notranslate">
order deny,allow
deny from all

# allow from example.dyndns.org
allow from 8.8.4.4
</pre>
<p>And your sed code to update the allowed IP address might look like this:</p>
<pre class="brush: plain; title: ; notranslate">
sed -i -r &quot;/# allow from example.dyndns.org/I{\
n; s/([0-9]{1,3}.){3}[0-9]{1,3}/8.8.8.8/\
}&quot; .htaccess
</pre>
<p>Let&#8217;s look at it piece by piece.</p>
<ul>
<li><strong>/# allow from example.dyndns.org/I</strong> will search the file for this string. The I flag at the end makes the search case insensitive.</li>
<li><strong>n;</strong> will tell sed to continue processing on the next line.</li>
<li><strong>s/([0-9]{1,3}\.){3}[0-9]{1,3}/8.8.8.8/</strong> will regex search for an IP and replace the match with your updated IP (in this case 8.8.8.8).</li>
<li><strong>.htaccess</strong> is of course the input file to process.</li>
</ul>
<p>Note that in .htaccess files, comments must be on a line of their own. End of line or inline comments are not permitted. In cases where you do not need to replace a part of the next line but rather all of it, our replacement becomes <strong>s/.*/8.8.8.8/</strong></p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2011/09/07/securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn/' rel='bookmark' title='Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)'>Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)</a></li>
<li><a href='http://blog.ergatides.com/2011/02/21/whats-my-ip-check-your-ip-address-from-the-command-line/' rel='bookmark' title='What&#8217;s my IP? Check your IP address from the command line.'>What&#8217;s my IP? Check your IP address from the command line.</a></li>
<li><a href='http://blog.ergatides.com/2010/02/24/handy-command-line-currency-converter/' rel='bookmark' title='Handy command line currency converter.'>Handy command line currency converter.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This example will show you how easy it is using sed to find a particular line in a file and replace all or part of the next line. In this example, using htaccess we want to deny access to all clients except a particular dynamic IP (for your home connection for instance).</p>
<p>Your .htaccess file might look like this:</p>
<pre class="brush: plain; title: ; notranslate">
order deny,allow
deny from all

# allow from example.dyndns.org
allow from 8.8.4.4
</pre>
<p>And your sed code to update the allowed IP address might look like this:</p>
<pre class="brush: plain; title: ; notranslate">
sed -i -r &quot;/# allow from example.dyndns.org/I{\
n; s/([0-9]{1,3}.){3}[0-9]{1,3}/8.8.8.8/\
}&quot; .htaccess
</pre>
<p>Let&#8217;s look at it piece by piece.</p>
<ul>
<li><strong>/# allow from example.dyndns.org/I</strong> will search the file for this string. The I flag at the end makes the search case insensitive.</li>
<li><strong>n;</strong> will tell sed to continue processing on the next line.</li>
<li><strong>s/([0-9]{1,3}\.){3}[0-9]{1,3}/8.8.8.8/</strong> will regex search for an IP and replace the match with your updated IP (in this case 8.8.8.8).</li>
<li><strong>.htaccess</strong> is of course the input file to process.</li>
</ul>
<p>Note that in .htaccess files, comments must be on a line of their own. End of line or inline comments are not permitted. In cases where you do not need to replace a part of the next line but rather all of it, our replacement becomes <strong>s/.*/8.8.8.8/</strong></p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2011/09/07/securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn/' rel='bookmark' title='Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)'>Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)</a></li>
<li><a href='http://blog.ergatides.com/2011/02/21/whats-my-ip-check-your-ip-address-from-the-command-line/' rel='bookmark' title='What&#8217;s my IP? Check your IP address from the command line.'>What&#8217;s my IP? Check your IP address from the command line.</a></li>
<li><a href='http://blog.ergatides.com/2010/02/24/handy-command-line-currency-converter/' rel='bookmark' title='Handy command line currency converter.'>Handy command line currency converter.</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2012/01/24/using-sed-to-search-and-replace-contents-of-next-line-in-a-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)</title>
		<link>http://blog.ergatides.com/2011/09/07/securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn</link>
		<comments>http://blog.ergatides.com/2011/09/07/securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 12:28:17 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cloudflare]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.ergatides.com/?p=1086</guid>


		<description><![CDATA[<p>You may wish to increase the security of your WordPress blog by doing this, or you may not. It&#8217;s a matter of preference. Before today I never bothered, but since I wanted to figure out how it can be done, now it makes no sense to remove the extra security.</p>
<p>In all cases, there are 2 areas that can be locked down from 2 separate .htaccess files. These are:</p>
<ul>
<li><strong>/wordpress/.htaccess</strong> to secure the wp-login.php file (used to log in).</li>
<li><strong>/wordpress/wp-admin/.htaccess</strong> to secure everything under the wp-admin directory.</li>
</ul>
<p>I want to allow only a few IP addresses to be able to access these areas. This is how it&#8217;s done without a cloud:</p>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/.htaccess
&lt;Files wp-login.php&gt;
    order deny,allow
    deny from all
    allow from 93.75.252.219
    allow from 110.170.50.32
&lt;/Files&gt;
</pre>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/wp-admin/.htaccess
order deny,allow
deny from all
allow from 93.75.252.219
allow from 110.170.50.32
</pre>
<p>Access to the login and admin areas of your website are now restricted to only the IPs you allow. If however, you are using a service like <a href="http://www.cloudflare.com/" target="_blank" title="CloudFlare">CloudFlare</a>, the above will not work because apache can&#8217;t see your (the visitor&#8217;s) IP address. Let&#8217;s fix this:</p>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/.htaccess
&lt;Files wp-login.php&gt;
    SetEnvIf X-FORWARDED-FOR 93.75.252.219 allowedip
    SetEnvIf X-FORWARDED-FOR 110.170.50.32 allowedip
    order deny,allow
    deny from all
    allow from allowedip
&lt;/Files&gt;
</pre>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/wp-admin/.htaccess
SetEnvIf X-FORWARDED-FOR 93.75.252.219 allowedip
SetEnvIf X-FORWARDED-FOR 110.170.50.32 allowedip
order deny,allow
deny from all
allow from allowedip
</pre>
<p>Apache is now reading your IP address and setting the <em>allowedip</em> environment variable which is then whitelisted on the last line.</p>
<p>Note that you should *not* rely on this security measure alone since an IP address you have whitelisted can and may be spoofed. Always monitor your access logs and combine this with other security methods (such as basic authentication for example) to further increase security.</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2012/01/24/using-sed-to-search-and-replace-contents-of-next-line-in-a-file/' rel='bookmark' title='Using sed to search and replace contents of next line in a file.'>Using sed to search and replace contents of next line in a file.</a></li>
<li><a href='http://blog.ergatides.com/2010/06/18/inove-theme-by-neoease-for-wordpress-3-0/' rel='bookmark' title='iNove theme by NeoEase for WordPress 3.0'>iNove theme by NeoEase for WordPress 3.0</a></li>
<li><a href='http://blog.ergatides.com/2011/06/08/cloudflare-threat-control-require-captcha-by-country/' rel='bookmark' title='CloudFlare threat control. Require captcha by country.'>CloudFlare threat control. Require captcha by country.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>You may wish to increase the security of your WordPress blog by doing this, or you may not. It&#8217;s a matter of preference. Before today I never bothered, but since I wanted to figure out how it can be done, now it makes no sense to remove the extra security.</p>
<p>In all cases, there are 2 areas that can be locked down from 2 separate .htaccess files. These are:</p>
<ul>
<li><strong>/wordpress/.htaccess</strong> to secure the wp-login.php file (used to log in).</li>
<li><strong>/wordpress/wp-admin/.htaccess</strong> to secure everything under the wp-admin directory.</li>
</ul>
<p>I want to allow only a few IP addresses to be able to access these areas. This is how it&#8217;s done without a cloud:</p>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/.htaccess
&lt;Files wp-login.php&gt;
    order deny,allow
    deny from all
    allow from 93.75.252.219
    allow from 110.170.50.32
&lt;/Files&gt;
</pre>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/wp-admin/.htaccess
order deny,allow
deny from all
allow from 93.75.252.219
allow from 110.170.50.32
</pre>
<p>Access to the login and admin areas of your website are now restricted to only the IPs you allow. If however, you are using a service like <a href="http://www.cloudflare.com/" target="_blank" title="CloudFlare">CloudFlare</a>, the above will not work because apache can&#8217;t see your (the visitor&#8217;s) IP address. Let&#8217;s fix this:</p>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/.htaccess
&lt;Files wp-login.php&gt;
    SetEnvIf X-FORWARDED-FOR 93.75.252.219 allowedip
    SetEnvIf X-FORWARDED-FOR 110.170.50.32 allowedip
    order deny,allow
    deny from all
    allow from allowedip
&lt;/Files&gt;
</pre>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/wp-admin/.htaccess
SetEnvIf X-FORWARDED-FOR 93.75.252.219 allowedip
SetEnvIf X-FORWARDED-FOR 110.170.50.32 allowedip
order deny,allow
deny from all
allow from allowedip
</pre>
<p>Apache is now reading your IP address and setting the <em>allowedip</em> environment variable which is then whitelisted on the last line.</p>
<p>Note that you should *not* rely on this security measure alone since an IP address you have whitelisted can and may be spoofed. Always monitor your access logs and combine this with other security methods (such as basic authentication for example) to further increase security.</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2012/01/24/using-sed-to-search-and-replace-contents-of-next-line-in-a-file/' rel='bookmark' title='Using sed to search and replace contents of next line in a file.'>Using sed to search and replace contents of next line in a file.</a></li>
<li><a href='http://blog.ergatides.com/2010/06/18/inove-theme-by-neoease-for-wordpress-3-0/' rel='bookmark' title='iNove theme by NeoEase for WordPress 3.0'>iNove theme by NeoEase for WordPress 3.0</a></li>
<li><a href='http://blog.ergatides.com/2011/06/08/cloudflare-threat-control-require-captcha-by-country/' rel='bookmark' title='CloudFlare threat control. Require captcha by country.'>CloudFlare threat control. Require captcha by country.</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2011/09/07/securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache virtual hosts, _default_ and ServerName</title>
		<link>http://blog.ergatides.com/2009/12/02/apache-virtual-hosts-_default_-and-servername/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=apache-virtual-hosts-_default_-and-servername</link>
		<comments>http://blog.ergatides.com/2009/12/02/apache-virtual-hosts-_default_-and-servername/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 20:20:59 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[ServerName]]></category>
		<category><![CDATA[_default_]]></category>

		<guid isPermaLink="false">http://ergatides.com/wordpress/?p=86</guid>


		<description><![CDATA[<p>I&#8217;ve recently changed my VPS provider. I won&#8217;t go into why, that&#8217;s a separate post for when I find the time and nerves to write about it.</p>
<p>Given the opportunity of the move, I decided to split my VirtualHost configuration out of a single httpd.conf file into per virtual-host config files. This by chance, is something that I knew that I could do since 1696 but never really realized the advantages of doing so before now.</p>
<p>Anyway, the mistake I made was to assign ServerName in httpd.conf to either a named or aliased VirtualHost. This caused a conflict which was solved as soon as I changed ServerName to something totally irrelevant.</p>
<p>No related posts.</p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently changed my VPS provider. I won&#8217;t go into why, that&#8217;s a separate post for when I find the time and nerves to write about it.</p>
<p>Given the opportunity of the move, I decided to split my VirtualHost configuration out of a single httpd.conf file into per virtual-host config files. This by chance, is something that I knew that I could do since 1696 but never really realized the advantages of doing so before now.</p>
<p>Anyway, the mistake I made was to assign ServerName in httpd.conf to either a named or aliased VirtualHost. This caused a conflict which was solved as soon as I changed ServerName to something totally irrelevant.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2009/12/02/apache-virtual-hosts-_default_-and-servername/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

