<?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>サイキョウライン &#187; Apache</title>
	<atom:link href="http://saikyoline.jp/weblog/category/apache/feed" rel="self" type="application/rss+xml" />
	<link>http://saikyoline.jp/weblog</link>
	<description>コンピュータに関係あることとか、ないこととか。</description>
	<lastBuildDate>Wed, 01 Feb 2012 14:17:56 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Apacheは知らないhttpステータスは返さない。</title>
		<link>http://saikyoline.jp/weblog/2010/02/11/132947.html</link>
		<comments>http://saikyoline.jp/weblog/2010/02/11/132947.html#comments</comments>
		<pubDate>Thu, 11 Feb 2010 04:29:47 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=921</guid>
		<description><![CDATA[正しくは、500を返す。 render :nothing =&#62; true, :status =&#62; 450 なんてことをしていて、Mongrelの開発環境だとちゃんと450が返ってくるのにApache+Pass [...]]]></description>
			<content:encoded><![CDATA[<p>正しくは、500を返す。</p>
<pre class="code"><code>render :nothing =&gt; true, :status =&gt; 450</code></pre>
<p>なんてことをしていて、Mongrelの開発環境だとちゃんと450が返ってくるのにApache+Passengerの検証環境だと500が返ってきていた。<br />
そこで原因を調べたところ、返す可能性のあるステータスコードはすべて定義されていて、それ以外は500で返している。（※ソースは後述）</p>
<p>で、なんでこんなことをしようとしているのか。Flashのアップローダを作って<a href="http://livedocs.adobe.com/flex/3_jp/langref/flash/net/FileReference.html#upload%28%29">FileReference#upload()</a>でアップロードしているのだけれど、こいつが結果をHTTPステータスでしか受け取れない。だから、結果のメッセージをサーバから返してそれを表示する、てこともできない。<br />
アップロード自体が成功したか否かを知るには200かそれ以外か、くらいで十分なんだけれど、アプリ要件（たとえば、アップロードが終わってからファイルを受け付けられない状況になってただとか、ファイルの中身を見て判断しなきゃいけないだとか）での結果を返すには、これでは足りない。<br />
結局、Apacheのソースコメントでunusedとなっていた418～421に意味を持たせ、そこを使って対応しました。層を混同していて気持ちがいいものではないのだけれど、影響範囲は広くなく、なんらかのフラグを立てて別リクエスト、のコスト増を考えるといいだろうとの判断。もしなにかいい方法があったら教えてください。</p>
<p>以下、Apacheソースの該当部分。<br />
<span id="more-921"></span><br />
<em>httpd-2.2.14/modules/http/http_protocol.c</em></p>
<pre class="code"><code> 731 AP_DECLARE(int) ap_index_of_response(int status)
 732 {
 733     static int shortcut[6] = {0, LEVEL_200, LEVEL_300, LEVEL_400,
 734     LEVEL_500, RESPONSE_CODES};
 735     int i, pos;
 736
 737     if (status &lt; 100) {               /* Below 100 is illegal for HTTP status */
 738         return LEVEL_500;
 739     }
 740
 741     for (i = 0; i &lt; 5; i++) {
 742         status -= 100;
 743         if (status &lt; 100) {
 744             pos = (status + shortcut[i]);
 745             if (pos &lt; shortcut[i + 1]) {
 746                 return pos;
 747             }
 748             else {
 749                 return LEVEL_500;            /* status unknown (falls in gap) */
 750             }
 751         }
 752     }
 753     return LEVEL_500;                         /* 600 or above is also illegal */
 754 }</code></pre>
<p><em>httpd-2.2.14/modules/http/http_protocol.c</em></p>
<pre class="code"><code>  99 #define LEVEL_400 19
 100     &quot;400 Bad Request&quot;,
 101     &quot;401 Authorization Required&quot;,
 102     &quot;402 Payment Required&quot;,
 103     &quot;403 Forbidden&quot;,
 104     &quot;404 Not Found&quot;,
 105     &quot;405 Method Not Allowed&quot;,
 106     &quot;406 Not Acceptable&quot;,
 107     &quot;407 Proxy Authentication Required&quot;,
 108     &quot;408 Request Time-out&quot;,
 109     &quot;409 Conflict&quot;,
 110     &quot;410 Gone&quot;,
 111     &quot;411 Length Required&quot;,
 112     &quot;412 Precondition Failed&quot;,
 113     &quot;413 Request Entity Too Large&quot;,
 114     &quot;414 Request-URI Too Large&quot;,
 115     &quot;415 Unsupported Media Type&quot;,
 116     &quot;416 Requested Range Not Satisfiable&quot;,
 117     &quot;417 Expectation Failed&quot;,
 118     &quot;418 unused&quot;,
 119     &quot;419 unused&quot;,
 120     &quot;420 unused&quot;,
 121     &quot;421 unused&quot;,
 122     &quot;422 Unprocessable Entity&quot;,
 123     &quot;423 Locked&quot;,
 124     &quot;424 Failed Dependency&quot;,
 125     /* This is a hack, but it is required for ap_index_of_response
 126      * to work with 426.
 127      */
 128     &quot;425 No code&quot;,
 129     &quot;426 Upgrade Required&quot;,</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2010/02/11/132947.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>バーチャルホストでSSL。</title>
		<link>http://saikyoline.jp/weblog/2006/11/08/010156.html</link>
		<comments>http://saikyoline.jp/weblog/2006/11/08/010156.html#comments</comments>
		<pubDate>Tue, 07 Nov 2006 16:01:56 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=343</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<blockquote cite="http://www.aconus.com/~oyaji/www/apache_win_virtual.htm" title="名前ベース・バーチャルホストWWWサーバの構築"><p><a href="http://www.aconus.com/~oyaji/www/apache_win_virtual.htm">名前ベース・バーチャルホストWWWサーバの構築</a></p>
<p>SSL セキュアサーバではアクセス時に最初に SSL の認証シーケンスが走ります。しかし、その時点では Apache はアクセスしてきたホスト名が分からないため、証明書の交換は先頭のバーチャルホストのデータを元に行われます。従って、<strong>名前ベースのバーチャルホストでは、SSL は一つのバーチャルホストしか扱えません。</strong></p></blockquote>
<p>ってことを知らなくて、ハマった。確かにどのホスト名でアクセスしてもひとつめのドキュメントルートが表示されてた。<br/><br />
で、IPベースはというと・・・</p>
<blockquote cite="http://httpd.apache.org/docs/2.2/vhosts/ip-based.html" title="Apache の IP ベースのバーチャルホストサポート - Apache HTTP サーバ"><p><a href="http://httpd.apache.org/docs/2.2/vhosts/ip-based.html">Apache の IP ベースのバーチャルホストサポート &#8211; Apache HTTP サーバ</a></p>
<p>IP ベース という名前が示すように、サーバには IP ベースのバーチャルホストそれぞれにつき、別々の IP アドレスが 必要です。複数の物理コネクションを持っているマシンを用意するか、 最近のオペレーティングシステムでサポートされているバーチャル インタフェース (詳細はシステムの説明書を読んでください。たいていは &#8220;ip エイリアス&#8221; と呼ばれていて、設定には普通 &#8220;ifconfig&#8221; コマンドを 使います) を使うかで実現できます。</p></blockquote>
<p>おーエイリアスでいいのか。こっちでいくか、外に出すものではないし。</p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2006/11/08/010156.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache黙る。</title>
		<link>http://saikyoline.jp/weblog/2006/09/30/230613.html</link>
		<comments>http://saikyoline.jp/weblog/2006/09/30/230613.html#comments</comments>
		<pubDate>Sat, 30 Sep 2006 14:06:13 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=327</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>突然Apacheが黙った。プロセスは生きてるっぽいけど画面真っ白。<br/><br />
error_logをみたらこんなのがいっぱい。</p>
<pre class="code"><code>...
[Sat Sep 30 21:27:18 2006] [notice] child pid 27980 exit signal File size limit exceeded (25)
[Sat Sep 30 21:27:18 2006] [notice] child pid 27981 exit signal File size limit exceeded (25)
[Sat Sep 30 21:27:18 2006] [notice] child pid 27982 exit signal File size limit exceeded (25)
[Sat Sep 30 21:27:18 2006] [notice] child pid 27983 exit signal File size limit exceeded (25)
[Sat Sep 30 21:27:18 2006] [notice] child pid 27985 exit signal File size limit exceeded (25)
...</code></pre>
<p>リミット？ってことでhttpd.confを確認してもそれらしきところはなく、ググってみたらApache-Usersのメーリングリストにレポートを発見。<br/><br />
<a href="http://mm.apache.or.jp/pipermail/apache-users/2005-February/005184.html">http://mm.apache.or.jp/pipermail/apache-users/2005-February/005184.html</a><br/><br />
おーなるほど。で、</p>
<pre class="code"><code>-rw-r--r--    1 root     root     2147483647  9月 30 21:00 rewrite_log</code></pre>
<p>これか。mod_rewriteのRewriteLogLevelを最大にしていたのを忘れてた。<br/><br />
わりとどうでもいいサーバだからって放置にも限度があるだろ的な。というか、ぴったり2GBってところになぜか感心。<br/><br />
またひとつ賢くなった・・・のか？</p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2006/09/30/230613.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apacheに標準で組み込まれるモジュール。</title>
		<link>http://saikyoline.jp/weblog/2006/01/24/234701.html</link>
		<comments>http://saikyoline.jp/weblog/2006/01/24/234701.html#comments</comments>
		<pubDate>Tue, 24 Jan 2006 14:47:01 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=179</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>分かってませんでしたシリーズ。<br/><br />
Apacheのconfigureオプションはenableとdisableがたくさんあって、デフォルトでどのモジュールが組み込まれるのかよく分かってませんでした。<br/><br />
そこで、このオプション。</p>
<pre class="code"><code># /usr/local/apache2/bin/httpd -l</code></pre>
<p>組み込まれてるモジュールが一覧されます。<br/><br />
ちなみにApache 2.2.0のデフォルトはこちら↓</p>
<pre class="code"><code>Compiled in modules:
core.c
mod_authn_file.c
mod_authn_default.c
mod_authz_host.c
mod_authz_groupfile.c
mod_authz_user.c
mod_authz_default.c
mod_auth_basic.c
mod_include.c
mod_filter.c
mod_log_config.c
mod_env.c
mod_setenvif.c
prefork.c
http_core.c
mod_mime.c
mod_status.c
mod_autoindex.c
mod_asis.c
mod_cgi.c
mod_negotiation.c
mod_dir.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_so.c</code></pre>
<p>コレを見てconfigureすればイイジャン！・・・って、コンパイルしないと見られないか。鶏と卵。</p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2006/01/24/234701.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache HTTP Server 2.2.0 Released.</title>
		<link>http://saikyoline.jp/weblog/2005/12/02/095608.html</link>
		<comments>http://saikyoline.jp/weblog/2005/12/02/095608.html#comments</comments>
		<pubDate>Fri, 02 Dec 2005 00:56:08 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=148</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a title="Apache HTTP Server Project" href="http://www.apache.org/dist/httpd/Announcement2.2.html">Apache HTTP Server Project</a></p>
<blockquote><p>The Apache Software Foundation and The Apache HTTP Server Project are pleased to announce the release of version 2.2.0 of the Apache HTTP Server (&#8220;Apache&#8221;).</p></blockquote>
<p>Apache 2.2.0がリリースされました。<br/><br />
これで安定リリースのApacheを使ってもmod_proxy_ajp(+mod_proxy)でTomcatとつなげるようになりました。<br/><br />
んが、<a href="http://tomcat.apache.org/faq/connectors.html">TomcatのサイトのコネクタFAQ</a>では</p>
<blockquote><p>mod_jk is great and should be used for production. It is getting fixes as needed (which is now rare).</p></blockquote>
<blockquote><p>mod_proxy_ajp. With apache 2.2, mod_proxy was rewritten to support load balancing as well as a new transport called mod_proxy_ajp. This module is distributed with the Apache http server, not the Tomcat server.</p></blockquote>
<p>となってます。<br/><br />
うーん、ちゃんとメリット、デメリットを理解しないとな。</p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2005/12/02/095608.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

