<?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>SKYCUBE.net &#187; apache</title>
	<atom:link href="http://skycube.net/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://skycube.net</link>
	<description>Projects, References and Personals by Per Lasse Baasch</description>
	<lastBuildDate>Fri, 29 Jul 2011 01:21:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Restricetd access to a web-application with htaccess or php</title>
		<link>http://skycube.net/2009/07/03/restricetd-access-to-a-web-application-with-htaccess-or-php/</link>
		<comments>http://skycube.net/2009/07/03/restricetd-access-to-a-web-application-with-htaccess-or-php/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 19:08:17 +0000</pubDate>
		<dc:creator>Per Lasse Baasch</dc:creator>
				<category><![CDATA[other]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.skycube.net/?p=96</guid>
		<description><![CDATA[If you building a simple web-application and you are not really sure, ow secure are the authentication and or the rest of the application you should think about to limit the access to the application. Furthermore, may your application should be available only for testing purpose of several customers the following could help you: First [...]]]></description>
			<content:encoded><![CDATA[<p>If you building a simple web-application and you are not really sure, ow secure are the authentication and or the rest of the application you should think about to limit the access to the application.<br />
Furthermore, may your application should be available only for testing purpose of several customers the following could help you:</p>
<p><strong>First way</strong>&#8230; using a <em>.htaccess</em> which controls the access using a apache web server.<br />
This is a very fast sollution <strong>BUT you CAN&#8217;T use</strong> <strong>hostnames</strong> and or full qualified <strong>dns names</strong> like skycube.net or yourname.dyndns.org</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>Limit GET HEAD POST<span style="color: #000000; font-weight: bold;">&gt;</span>
order deny,allow
allow from 62.75.185.219
allow from 127.0.1.1
allow from 127.0.0.1
deny from all
<span style="color: #000000; font-weight: bold;">&lt;/</span>Limit<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<hr style="margin: 10px;" />
<p><strong>The second way</strong>&#8230; which I prefer, using a php code snippet. This allows you to <strong>use hostnames and full qualified domain names</strong>. Definitely you can write it in less than the lines I used below for the code, but in of understanding what the code does, it&#8217;s better <img src='http://skycube.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * ACL array
 */</span>
<span style="color: #000088;">$valid_hosts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'127.0.0.1'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'127.0.1.1'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'yourname.dyndns.org'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'skycube.net'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span>sizeof<span style="color: #009900;">&#40;</span><span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$valid_ip</span> <span style="color: #339933;">=</span> <span style="color: #990000;">gethostbyname</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$valid_ip</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$valid_state</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'valid'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$valid_state</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'invalid'</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$valid_state</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'valid'</span><span style="color: #009900;">&#41;</span>
  <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: http://www.skycube.net&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://skycube.net/2009/07/03/restricetd-access-to-a-web-application-with-htaccess-or-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Session problems</title>
		<link>http://skycube.net/2009/02/21/session-problems/</link>
		<comments>http://skycube.net/2009/02/21/session-problems/#comments</comments>
		<pubDate>Sat, 21 Feb 2009 01:20:54 +0000</pubDate>
		<dc:creator>Per Lasse Baasch</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.skycube.net/?p=40</guid>
		<description><![CDATA[While you working with web applications it could happen that you get several errors.. Never underestimate real server problems. When you try to start a new Web 2.0 application or just the usage and/or visits of your application increase, maybe non-linear, you can login to your application but you can&#8217;t proceed. On enterprise applications it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>While you working with web applications it could happen that you get several errors.. Never underestimate real server problems. When you try to start a new <strong>Web 2.0</strong> application or just the usage and/or visits of your application increase, maybe non-linear, you can login to your application but you can&#8217;t proceed.</p>
<p>On enterprise applications it&#8217;s recommended to set <strong><em>php display errors to off</em></strong>, so won&#8217;t see what really happened.</p>
<p>While tracking the problem to your browser and the customers and may the service provider, you should just login with a shell.<br />
First thing you should do is, like all time, who and last. After that, may you try to find out what happen in the apache access and error log. You will find nothing, cause there is nothing critical, nothing new. May you see the session file in your filesystem, but why is it empty? A php bug?</p>
<p>Why? Ok just the answer, try this: <strong><em>df -h</em></strong> , you will see the a 100% full partition <img src='http://skycube.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   and when you try a <strong><em>du -shm /var/log/*</em></strong> you see your problem&#8230; GB&#8217;s of apache logs&#8230;</p>
<p>What happened? Your Web 2.0 application uses <strong>polling</strong>, and your apache got a custom, combined log which writes to access.log.</p>
<ul>
<li> Solution 1: Drop the line in your apache virtualhost configuration for custom, combined log</li>
</ul>
<ul>
<li> Solution 2: Proceed a massive logrotation</li>
</ul>
<ul>
<li> Solution 3: Pipe the combined  log to a perl or php-cli script which filters the polling events (I prefer)</li>
</ul>
<p>On local, staging and or development installations you should switch the display errors for php to on,&#8230; then you get messages like this:<br />
<code><br />
WARNING: session_write_close() [function.session-write-close]...<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://skycube.net/2009/02/21/session-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

