[[PageOutline]] [[TitleIndex(TipAndDoc/network/httpd,format=group)]] * [http://d.hatena.ne.jp/indication/20110102/1293987933 Apache2におけるマルチユーザー環境(apache2-mpm-itkで権限分離編) - test] * [http://blog.shiten.info/2010/05/ubuntu-10-04-%E3%81%AE-apache2-userdir-%E3%81%A7-php-%E3%81%8C%E5%8B%95%E3%81%8B%E3%81%AA%E3%81%84%E4%BB%B6.html blog.shiten.info » Ubuntu 10.04 の Apache2 userdir で PHP が動かない件] > /etc/apache2/mods-available/php5.conf の以下のコンフィグをコメントアウトします。 > {{{ > # php_admin_value engine Off > }}} * see also [http://php.net/manual/ja/configuration.changes.php PHP: 設定を変更するには - Manual] * http://wiki.apache.org/httpd/InternalDummyConnection > When the Apache HTTP Server manages its child processes, it needs a way to wake up processes that are listening for new connections. To do this, it sends a simple HTTP request back to itself. This request will appear in the access_log file with the remote address set to the loop-back interface (typically 127.0.0.1 or ::1 if IPv6 is configured). If you log the User-Agent string (as in the combined log format), you will see the server signature followed by "(internal dummy connection)" on non-SSL servers. During certain periods you may see up to one such request for each httpd child process. * [http://blog.dacelo.info/apache/entry-697.html .htaccessでSSL(https)必須にする “SSLRequireSSL” | Weblogy] > .htaccess に > {{{SSLRequireSSL}}} > と書くだけで、そのディレクトリ以下はSSL必須となり、httpの場合はAccess Forbiddenになります。 = suEXEC = * [http://www.parlia.net/weblog/post/729.html/ suEXECのドキュメントルートを変更する – 片っ端からメモってみる] * [http://snoop.to/bbbs/logs/20081129221405.html UbuntuWWWサーバのセットアップ / MeMoGaKi] * [http://d.hatena.ne.jp/magicalhat/20081226/1230220014 特定の VirtualHost でのみ SuEXEC したい - ふしぎなぼうし] * [http://d.hatena.ne.jp/indication/20110101/1293899867 Apache2におけるマルチユーザー環境(php-cgi+fcgid+suexecで権限分離編) - test] = Server Maintenance = * [http://wiki.princo.org/?%B0%EC%BB%FE%C5%AA%A4%CB%A4%B9%A4%D9%A4%C6%A4%CEURL%A4%D8%A4%CE%A5%EA%A5%AF%A5%A8%A5%B9%A5%C8%A4%F2''%A5%E1%A5%F3%A5%C6%A5%CA%A5%F3%A5%B9%C3%E6''%C9%BD%BC%A8%A4%CB%A4%B9%A4%EB 一時的にすべてのURLへのリクエストを''メンテナンス中''表示にする - いろいろwiki@princo.org] * [http://web-tan.forum.impressrd.jp/e/2009/06/16/5880 メンテナンス中画面を出す正しい作法と.htaccessの書き方 | Web担当者Forum] * ex) /etc/apache2/sites-available/default {{{ RewriteEngine On RewriteCond %{REQUEST_URI} !^/maintenance/.* RewriteRule ^.*$ - [R=503,L] ErrorDocument 503 /maintenance/ }}} = Name-based VirtualHost with SSL = * [http://kjirou.sakura.ne.jp/wiki_mirror/index.php?a%2FApache#q549090f 名前ベースのバーチャルホストで複数ドメインにSSLを割り当てることは可能か?] * 本質的な問題 {{{ HTTP プロトコルと SSL の原理を考えてみても不可能なことは明らかですね。 ネームベースのバーチャルホストは、HTTP リクエストヘッダに含まれる「Host」を参照 して アクセスするバーチャルホストを変化させますが、 SSL 接続の場合、HTTP リクエストヘッダは暗号化されており、 参照することができません。 参照するためには、暗号を解読してやればよいわけですが、 暗号を解読するためには先に証明書の交換を行う必要がありますね。 }}} * [http://httpd.apache.org/docs/2.2/ssl/ssl_faq.html#vhosts2 Why is it not possible to use Name-Based Virtual Hosting to identify different SSL virtual hosts?] * It is possible, but only if using a 2.2.12 or later web server, built with 0.9.8j or later OpenSSL. This is because it requires a feature that only the most recent revisions of the SSL specification added, called Server Name Indication (SNI). * The reason is that the SSL protocol is a separate layer which encapsulates the HTTP protocol. So the SSL session is a separate transaction, that takes place before the HTTP session has begun. The server receives an SSL request on IP address X and port Y (usually 443). Since the SSL request did not contain any Host: field, the server had no way to decide which SSL virtual host to use. Usually, it just used the first one it found which matched the port and IP address specified. * ただし、全てのVirtualHostで同じワイルドカード証明書を指定すれば可能 = mod_proxy = * SSLProxyEngine * リバースプロキシでSSL接続をする際に必要 {{{ [Tue Sep 21 02:05:25 2010] [error] proxy: HTTPS: failed to enable ssl support for 127.0.0.1:443 (localhost) }}} * [http://on-o.com/page/diary/20090804.html わんこ日記(2009-08-04)] * [http://d.hatena.ne.jp/bushimichi/20090417/1239970196 mod_proxy でバックエンドにSSLを利用する設定 - bushimichiの日記] * [http://blog.livedoor.jp/kotesaki/archives/1280430.html こてさきAjax:apacheでBasic認証がある場合の多段proxy - livedoor Blog(ブログ)] = mod_rewrite = * [http://net-newbie.com/trans/mod_rewrite.html Apache module mod_rewrite] * 日本語訳 * [http://japache.infoscience.co.jp/rewriteguide/ Apache URL Rewriting Guide] * 日本語訳/例が多く載っている * [http://tm.root-n.com/server:apache:module:rewrite apache :: Rewrite(mod_rewrite) Tipsというかメモ] * 複数行に渡って記述する際の例 * [http://maihy.com/hp/phptech/phptech_url_rew.html URL 書き換え( mod_rewrite ):とことん!ホームページ] * [http://tech.bayashi.jp/archives/entry/techweb/2007/001981.html mod_rewrite サンプル集/楽] > Apache1.X 系で mod_rewrite を使う場合、URLに「%2F」が含まれると思い通りに動作しない問題があります。 > (Apache2.X 系でも同様ですが、Apache2.0.46 以降では「AllowEncodedSlashes On」により回避できます。) * [http://tech.bayashi.jp/archives/entry/techweb/2007/001995.html mod_rewriteでQUERY_STRINGをゴニョゴニョする/楽] > クエリーを残したままリダイレクトするには [QSA] オプションをつける。 * [http://blog.jojo.jp/?eid=1068256 BASIC認証にて、REMOTE_USERによりコンテンツを切替 | 作業日報] * [http://www.kawaz.jp/pukiwiki/?mod_rewrite ずんWiki - mod_rewrite] > クッキーを見てリダイレクトさせる。 > /auth-area/ 以下のアクセスで、login というクッキーが無い場合はログイン画面(/login.php)に飛ばすようにするには以下のように書けば良いと思う。 {{{ RewriteEngine on RewriteBase /auth-area/ RewriteCond %{HTTP_COOKIE} !login= RewriteRule ^.*$ /login.php [R] }}} > HTTP_X_FORWARDED_FOR を RewriteCond で使うには? {{{ RewriteCond %{HTTP:X-Forwarded-For} !^192\.168\. }}} * [http://d.hatena.ne.jp/y-kawaz/20071010/1192076717 mod_rewrite で RBL を使ったアクセス制御を行う - y-kawazの日記] > 以下のような仕様のプログラムを、ここでは /etc/httpd/conf/bin/rbl_map.pl というファイル名で作成します。 {{{#!perl #!/usr/bin/perl use strict; use Socket qw(inet_aton); my @RBL_SERVERS = ('niku.2ch.net'); $| = 1; while() { chomp; my $ip = $_; my $revip = join('.', reverse(split(/\./, $ip))); my $status = 'HAM'; foreach my $server (@RBL_SERVERS) { if(inet_aton("$revip.$server")) { $status = "SPAM"; last; } } print "$status\n"; } }}} > httpd.conf に以下のように記述します。 {{{ RewriteEngine on RewriteMap rbl-map prg:/etc/httpd/conf/bin/rbl_map.pl RewriteCond %{REQUEST_URI} ^/rbltest/ RewriteCond ${rbl-map:%{REMOTE_ADDR}} SPAM RewriteRule (.*) SPAM [F] }}} * [http://d.hatena.ne.jp/m_kawanon/20101122/1290413415 リンク切れを起こさないための保険 - kawanon] > RewriteRule に NE (noescape) が無いと、Wiki などクエリに % が含まれる場合に %25 に変換されてしまい、正常にアクセスできないので注意してください。 * [http://q.hatena.ne.jp/1239105148 mod_rewriteの質問です。「RewriteCond %{REQUEST_FILENAME} !-f.. - 人力検索はてな] * VirtualHostディレクティブ直下に「RewriteCond %{REQUEST_FILENAME} !-f」を設定しても正しく機能しない * Directoryディレクティブ以下で設定すれば良い = ScriptAlias = * Apache/2.2.22 * /home/mitty/env.cgi {{{#!perl #!/usr/bin/perl -w print "Content-Type: text/plain\r\n\r\n"; foreach $key (sort(keys %ENV)) { print "$key = $ENV{$key}\n"; } print "--------------------\n"; use CGI; my $cgi = CGI->new; print "url => ", $cgi->url(), "\n"; print "url(absolute) => ", $cgi->url(-absolute => 1), "\n"; print "url(base) => ", $cgi->url(-base => 1), "\n"; }}} ||= Apache Conf =||= wget https://lab.mitty.jp/env/ =||= wget https://lab.mitty.jp/env/hoge =|| ||ScriptAlias /env /home/mitty/env.cgi [[br]] ScriptAlias /env /home/mitty/env.cgi/ [[br]] ScriptAlias /env/ /home/mitty/env.cgi/||PATH_INFO = / [[br]] PATH_TRANSLATED = /path/to/docroot/index.html [[br]] QUERY_STRING = [[br]] REQUEST_METHOD = GET [[br]] REQUEST_URI = /env/ [[br]] SCRIPT_FILENAME = /home/mitty/env.cgi [[br]] SCRIPT_NAME = /env [[br]] SCRIPT_URI = https://lab.mitty.jp/env/ [[br]] SCRIPT_URL = /env/ [[br]] -------------------- [[br]] url => https://lab.mitty.jp/env [[br]] url(absolute) => /env [[br]] url(base) => https://lab.mitty.jp||PATH_INFO = /hoge [[br]] PATH_TRANSLATED = /path/to/docroot/hoge [[br]] QUERY_STRING = [[br]] REQUEST_METHOD = GET [[br]] REQUEST_URI = /env/hoge [[br]] SCRIPT_FILENAME = /home/mitty/env.cgi [[br]] SCRIPT_NAME = /env [[br]] SCRIPT_URI = https://lab.mitty.jp/env/hoge [[br]] SCRIPT_URL = /env/hoge [[br]] -------------------- [[br]] url => https://lab.mitty.jp/env [[br]] url(absolute) => /env [[br]] url(base) => https://lab.mitty.jp|| ||ScriptAlias /env/ /home/mitty/env.cgi ||QUERY_STRING = [[br]] REQUEST_METHOD = GET [[br]] REQUEST_URI = /env/ [[br]] SCRIPT_FILENAME = /home/mitty/env.cgi [[br]] SCRIPT_NAME = /env/ [[br]] SCRIPT_URI = https://lab.mitty.jp/env/ [[br]] SCRIPT_URL = /env/ [[br]] -------------------- [[br]] url => https://lab.mitty.jp/env/ [[br]] url(absolute) => /env/ [[br]] url(base) => https://lab.mitty.jp||404 Not Found [[br]] {{{script not found or unable to stat: /home/mitty/env.cgihoge}}}||