設定 †http.conf †書きかけ。 ServerRoot "/usr/local/apache2" # Mutex default:logs #Listen 12.34.56.78:80 Listen 80 モジュールの類いはまだ整理出来ていないので 全部入りでmakeして、ここで取捨選択。 ここでは基本的かつ典型的なHTTPサーバを目的とする。 LoadModule authn_file_module modules/mod_authn_file.so #LoadModule authn_dbm_module modules/mod_authn_dbm.so #LoadModule authn_anon_module modules/mod_authn_anon.so #LoadModule authn_dbd_module modules/mod_authn_dbd.so #LoadModule authn_socache_module modules/mod_authn_socache.so LoadModule authn_core_module modules/mod_authn_core.so LoadModule authz_host_module modules/mod_authz_host.so LoadModule authz_groupfile_module modules/mod_authz_groupfile.so LoadModule authz_user_module modules/mod_authz_user.so #LoadModule authz_dbm_module modules/mod_authz_dbm.so #LoadModule authz_owner_module modules/mod_authz_owner.so #LoadModule authz_dbd_module modules/mod_authz_dbd.so LoadModule authz_core_module modules/mod_authz_core.so LoadModule access_compat_module modules/mod_access_compat.so LoadModule auth_basic_module modules/mod_auth_basic.so #LoadModule auth_form_module modules/mod_auth_form.so LoadModule auth_digest_module modules/mod_auth_digest.so #LoadModule allowmethods_module modules/mod_allowmethods.so #LoadModule file_cache_module modules/mod_file_cache.so #LoadModule cache_module modules/mod_cache.so #LoadModule cache_disk_module modules/mod_cache_disk.so #LoadModule socache_shmcb_module modules/mod_socache_shmcb.so #LoadModule socache_dbm_module modules/mod_socache_dbm.so #LoadModule socache_memcache_module modules/mod_socache_memcache.so #LoadModule watchdog_module modules/mod_watchdog.so #LoadModule dbd_module modules/mod_dbd.so #LoadModule dumpio_module modules/mod_dumpio.so #LoadModule echo_module modules/mod_echo.so #LoadModule buffer_module modules/mod_buffer.so #LoadModule data_module modules/mod_data.so #LoadModule ratelimit_module modules/mod_ratelimit.so LoadModule reqtimeout_module modules/mod_reqtimeout.so #LoadModule ext_filter_module modules/mod_ext_filter.so #LoadModule request_module modules/mod_request.so #LoadModule include_module modules/mod_include.so LoadModule filter_module modules/mod_filter.so #LoadModule reflector_module modules/mod_reflector.so #LoadModule substitute_module modules/mod_substitute.so #LoadModule sed_module modules/mod_sed.so #LoadModule charset_lite_module modules/mod_charset_lite.so #LoadModule deflate_module modules/mod_deflate.so #LoadModule xml2enc_module modules/mod_xml2enc.so #LoadModule proxy_html_module modules/mod_proxy_html.so LoadModule mime_module modules/mod_mime.so LoadModule log_config_module modules/mod_log_config.so #LoadModule log_debug_module modules/mod_log_debug.so #LoadModule log_forensic_module modules/mod_log_forensic.so #LoadModule logio_module modules/mod_logio.so LoadModule env_module modules/mod_env.so #LoadModule mime_magic_module modules/mod_mime_magic.so #LoadModule expires_module modules/mod_expires.so LoadModule headers_module modules/mod_headers.so #LoadModule usertrack_module modules/mod_usertrack.so #LoadModule unique_id_module modules/mod_unique_id.so LoadModule setenvif_module modules/mod_setenvif.so LoadModule version_module modules/mod_version.so #LoadModule remoteip_module modules/mod_remoteip.so #LoadModule proxy_module modules/mod_proxy.so #LoadModule proxy_connect_module modules/mod_proxy_connect.so #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so #LoadModule proxy_http_module modules/mod_proxy_http.so #LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so #LoadModule proxy_scgi_module modules/mod_proxy_scgi.so #LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so #LoadModule proxy_ajp_module modules/mod_proxy_ajp.so #LoadModule proxy_balancer_module modules/mod_proxy_balancer.so #LoadModule proxy_express_module modules/mod_proxy_express.so #LoadModule session_module modules/mod_session.so #LoadModule session_cookie_module modules/mod_session_cookie.so #LoadModule session_crypto_module modules/mod_session_crypto.so #LoadModule session_dbd_module modules/mod_session_dbd.so #LoadModule slotmem_shm_module modules/mod_slotmem_shm.so #LoadModule slotmem_plain_module modules/mod_slotmem_plain.so LoadModule ssl_module modules/mod_ssl.so #LoadModule dialup_module modules/mod_dialup.so #LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so #LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so #LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so #LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so LoadModule mpm_event_module modules/mod_mpm_event.so LoadModule unixd_module modules/mod_unixd.so #LoadModule heartbeat_module modules/mod_heartbeat.so #LoadModule heartmonitor_module modules/mod_heartmonitor.so #LoadModule dav_module modules/mod_dav.so LoadModule status_module modules/mod_status.so LoadModule autoindex_module modules/mod_autoindex.so #LoadModule asis_module modules/mod_asis.so #LoadModule info_module modules/mod_info.so #LoadModule cgid_module modules/mod_cgid.so #LoadModule dav_fs_module modules/mod_dav_fs.so #LoadModule dav_lock_module modules/mod_dav_lock.so LoadModule vhost_alias_module modules/mod_vhost_alias.so #LoadModule negotiation_module modules/mod_negotiation.so LoadModule dir_module modules/mod_dir.so #LoadModule actions_module modules/mod_actions.so #LoadModule speling_module modules/mod_speling.so #LoadModule userdir_module modules/mod_userdir.so LoadModule alias_module modules/mod_alias.so LoadModule rewrite_module modules/mod_rewrite.so <IfModule unixd_module> User daemon Group daemon </IfModule> ServerAdmin you@example.com ServerName www.example.com:80 以下、OrderではなくRequireになっているので注意。 <Directory /> AllowOverride none Require all denied </Directory> DocumentRoot "/usr/local/apache2/htdocs" <Directory "/usr/local/apache2/htdocs"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> <Files ".ht*"> Require all denied </Files> ErrorLog "logs/error_log" LogLevel warn <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> #CustomLog "logs/access_log" common CustomLog "logs/access_log" combined </IfModule> <IfModule alias_module> # Redirect permanent /foo http://www.example.com/bar # Alias /webpath /full/filesystem/path #ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/" </IfModule> <IfModule cgid_module> #Scriptsock logs/cgisock </IfModule> <Directory "/usr/local/apache2/cgi-bin"> AllowOverride None Options None Require all granted </Directory> <IfModule mime_module> TypesConfig conf/mime.types #AddType application/x-gzip .tgz #AddEncoding x-compress .Z #AddEncoding x-gzip .gz .tgz AddType application/x-compress .Z AddType application/x-gzip .gz .tgz #AddHandler cgi-script .cgi #AddHandler type-map var #AddType text/html .shtml #AddOutputFilter INCLUDES .shtml </IfModule> #MIMEMagicFile conf/magic #ErrorDocument 500 "The server made a boo boo." #ErrorDocument 404 /missing.html #ErrorDocument 404 "/cgi-bin/missing_handler.pl" #ErrorDocument 402 http://www.example.com/subscription_info.html Apache Killerで一躍有名になったRangeリクエストに対し いくつまで返答するか。規定値は200。 #MaxRanges unlimited 関係するディレクティブは #MaxRangeReversals 400-500,100-130のようなリクエストに対する返答数。規定値20。 #MaxRangeOverlaps 100-200,150-300 〃 規定値はいずれもON。 ドキュメント参照のこと。 #EnableMMAP off #EnableSendfile on # Server-pool management (MPM specific) Include conf/extra/httpd-mpm.conf # Multi-language error messages #Include conf/extra/httpd-multilang-errordoc.conf # Fancy directory listings #Include conf/extra/httpd-autoindex.conf # Language settings #Include conf/extra/httpd-languages.conf # User home directories #Include conf/extra/httpd-userdir.conf # Real-time info on requests and configuration Include conf/extra/httpd-info.conf # Virtual hosts Include conf/extra/httpd-vhosts.conf # Local access to the Apache HTTP Server Manual #Include conf/extra/httpd-manual.conf # Distributed authoring and versioning (WebDAV) #Include conf/extra/httpd-dav.conf # Various default settings Include conf/extra/httpd-default.conf リバースプロキシ時にHTMLのURIマークアップなんかをバックエンド用から フロントエンド用にリライトしたりするやーつ。 # Configure mod_proxy_html to understand HTML4/XHTML1 <IfModule proxy_html_module> Include conf/extra/proxy-html.conf </IfModule> # Secure (SSL/TLS) connections Include conf/extra/httpd-ssl.conf # # Note: The following must must be present to support # starting without SSL on platforms with no /dev/random equivalent # but a statically compiled-in mod_ssl. # <IfModule ssl_module> SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule> httpd-autoindex.conf †ディレクトリ表示させたときの表示設定。 IndexOptions FancyIndexing HTMLTable VersionSort Alias /icons/ "/usr/local/apache2/icons/" OrderからRequireに変更。 <Directory "/usr/local/apache2/icons"> Options Indexes MultiViews AllowOverride None Require all granted </Directory> AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip AddIconByType (TXT,/icons/text.gif) text/* AddIconByType (IMG,/icons/image2.gif) image/* AddIconByType (SND,/icons/sound2.gif) audio/* AddIconByType (VID,/icons/movie.gif) video/* AddIcon /icons/binary.gif .bin .exe AddIcon /icons/binhex.gif .hqx AddIcon /icons/tar.gif .tar AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip AddIcon /icons/a.gif .ps .ai .eps AddIcon /icons/layout.gif .html .shtml .htm .pdf AddIcon /icons/text.gif .txt AddIcon /icons/c.gif .c AddIcon /icons/p.gif .pl .py AddIcon /icons/f.gif .for AddIcon /icons/dvi.gif .dvi AddIcon /icons/uuencoded.gif .uu AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl AddIcon /icons/tex.gif .tex AddIcon /icons/bomb.gif core AddIcon /icons/back.gif .. AddIcon /icons/hand.right.gif README AddIcon /icons/folder.gif ^^DIRECTORY^^ AddIcon /icons/blank.gif ^^BLANKICON^^ DefaultIcon /icons/unknown.gif #AddDescription "GZIP compressed document" .gz #AddDescription "tar archive" .tar #AddDescription "GZIP compressed tar archive" .tgz ReadmeName README.html HeaderName HEADER.html IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t httpd-dav.conf †WebDAVの設定。ウチは使っていない。 # Required modules: mod_alias, mod_auth_digest, mod_authn_core, mod_authn_file, # mod_authz_core, mod_authz_user, mod_dav, mod_dav_fs, # mod_setenvif DavLockDB "/usr/local/apache2/var/DavLock" ロックファイルの指定。 Alias /uploads "/usr/local/apache2/uploads" <Directory "/usr/local/apache2/uploads"> Dav On AuthType Digest AuthName DAV-upload Digest認証を使用。 AuthUserFile "/usr/local/apache2/user.passwd" AuthDigestProvider file adminさん以外はPUTとか禁止な。 <RequireAny> Require method GET POST OPTIONS Require user admin </RequireAny> </Directory> 具合の悪いクライアントへの対応。 BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully BrowserMatch "MS FrontPage" redirect-carefully BrowserMatch "^WebDrive" redirect-carefully BrowserMatch "^WebDAVFS/1.[01234]" redirect-carefully BrowserMatch "^gnome-vfs/1.0" redirect-carefully BrowserMatch "^XML Spy" redirect-carefully BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully BrowserMatch " Konqueror/4" redirect-carefully httpd-default.conf †基本設定。 Timeout 300 KeepAlive On HTTP1.1(と1.0拡張)で有効。 MaxKeepAliveRequests 100 KeepAliveの間処理出来るリクエストの数。 100なら100個のリクエストを処理したら接続を切る。 0で無制限になるのだが、プロセスなりスレッドなり 無駄が増えるので相当リッチな鯖でもそれはやめた方がいい。 KeepAliveTimeout 5 次のリクエストを待つ秒数。 5なら5秒待ってリクエストがなかったら接続を切る。 UseCanonicalName Off これちょっとややこしい。 Apacheが自分の名前をServerNameディレクティブの内容を見て決めるか クライアントから言われた名前にしちゃうかの設定。 ServerName www.example.jp:80と設定、 イントラではhostsでdevelopと設定、 クライアントが"http://develop/hoge"と最後のスラッシュなしで hogeディレクトリにアクセスしたとする。 Onの場合:ServerNameを見るのでhttp://www.example.jp/hoge/に mod_dirがスラッシュつけてリダイレクトする。 イントラ側で"www.example.jp"のIPアドレスが引けなければアウト。 Offの場合:クライアントが言う名前を使うのでhttp://develop/hoge/に mod_dirがスラッシュつけてリダイレクトする。 イントラ側ではhostsでIPアドレスが引けるのでおk。 通常はOffでの運用となるでしょう( ´ω`) よく「最後にスラッシュつけるつけないの設定!」と 思われているようですが違いますヨ。 (それはDirectorySlashで、これをOffにする理由はない) AccessFileName .htaccess ServerTokens Full ServerSignature On セキュリティの為に隠しましょう! とか言われてましたけど、ぶっちゃけ臭いものに蓋をしてるだけ。 隠す前に対策しましょうや( ´ω`) HostnameLookups On 名前引くか引かないかですけど ウチは弱小だし引く(`・ω・´)! TraceEnable Off TRACEメソッド禁止。通常運用時はOffでしょう。 クライアント(ブラウザとか)からのリクエストヘッダとリクエストボディの受付待ち時間。 以下の場合 <IfModule reqtimeout_module> RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500 </IfModule> 1.リクエストヘッダが来るまで20秒待つ 2.500byte受け取るごとに1秒延長する。ただし40秒までしか待たない 3.リクエストボディも20秒待つ 4.500byte受け取るごとに上限なしに1秒延長する。 5.タイムアウトしたらステータスコード408(Request Timeout)を返す マニュアル意訳。 このディレクティブはクライアントからのリクエストヘッダとリクエストボディ受付タイムアウトを設定します。 クライアントが設定された時間内にヘッダーまたは本文の送信に失敗した場合 408 REQUEST TIME OUTエラーが送信されます。 SSLバーチャルホストの場合、ヘッダーのタイムアウト値は 最初のSSLハンドシェイクを行うために必要な時間を考慮します。 ユーザーのブラウザがCRLを問い合わせるよう設定されており、CRLサーバから返事がなかった場合など ブラウザがCRLをあきらめるまで、最初のSSLハンドシェイクはかなりの時間がかかることがあります。 なのでヘッダーのタイムアウト値は、SSLバーチャルホストについては 非常に低い値を設定するべきではありません。 ボディのタイムアウト値は、SSLの再ネゴシエーション(必要な場合)に必要な時間を考慮します。 AcceptFilterディレクティブを使用する(通常はLinuxやFreeBSD上での場合)場合 少なくとも1byte(またはBSDのhttpready指定時にはリクエスト全体を)受け取るまでは ソケットはサーバプロセスへ送りません。 RequestReadTimeoutディレクティブで設定したリクエストヘッダのタイムアウトは ソケットからサーバプロセスが受け取った後にのみ有効です。 httpd-info.conf †サーバのリクエスト状況やらプロセス状態やらなんやらの表示設定。 OrderからRequireに変更。 <Location /server-status> SetHandler server-status Require host .example.com Require ip 127 </Location> #ExtendedStatus On <Location /server-info> SetHandler server-info Require host .example.com Require ip 127 </Location> httpd-language.conf †コンテントネゴシエーションでの言語設定。 # DefaultLanguage nl AddLanguage ca .ca AddLanguage cs .cz .cs AddLanguage da .dk AddLanguage de .de AddLanguage el .el AddLanguage en .en AddLanguage eo .eo AddLanguage es .es AddLanguage et .et AddLanguage fr .fr AddLanguage he .he AddLanguage hr .hr AddLanguage it .it AddLanguage ja .ja AddLanguage ko .ko AddLanguage ltz .ltz AddLanguage nl .nl AddLanguage nn .nn AddLanguage no .no AddLanguage pl .po AddLanguage pt .pt AddLanguage pt-BR .pt-br AddLanguage ru .ru AddLanguage sv .sv AddLanguage tr .tr AddLanguage zh-CN .zh-cn AddLanguage zh-TW .zh-tw LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv tr zh-CN zh-TW ForceLanguagePriority Prefer Fallback AddCharset us-ascii.ascii .us-ascii AddCharset ISO-8859-1 .iso8859-1 .latin1 AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen AddCharset ISO-8859-3 .iso8859-3 .latin3 AddCharset ISO-8859-4 .iso8859-4 .latin4 AddCharset ISO-8859-5 .iso8859-5 .cyr .iso-ru AddCharset ISO-8859-6 .iso8859-6 .arb .arabic AddCharset ISO-8859-7 .iso8859-7 .grk .greek AddCharset ISO-8859-8 .iso8859-8 .heb .hebrew AddCharset ISO-8859-9 .iso8859-9 .latin5 .trk AddCharset ISO-8859-10 .iso8859-10 .latin6 AddCharset ISO-8859-13 .iso8859-13 AddCharset ISO-8859-14 .iso8859-14 .latin8 AddCharset ISO-8859-15 .iso8859-15 .latin9 AddCharset ISO-8859-16 .iso8859-16 .latin10 AddCharset ISO-2022-JP .iso2022-jp .jis AddCharset ISO-2022-KR .iso2022-kr .kis AddCharset ISO-2022-CN .iso2022-cn .cis AddCharset Big5.Big5 .big5 .b5 AddCharset cn-Big5 .cn-big5 # For russian, more than one charset is used (depends on client, mostly): AddCharset WINDOWS-1251 .cp-1251 .win-1251 AddCharset CP866 .cp866 AddCharset KOI8 .koi8 AddCharset KOI8-E .koi8-e AddCharset KOI8-r .koi8-r .koi8-ru AddCharset KOI8-U .koi8-u AddCharset KOI8-ru .koi8-uk .ua AddCharset ISO-10646-UCS-2 .ucs2 AddCharset ISO-10646-UCS-4 .ucs4 AddCharset UTF-7 .utf7 AddCharset UTF-8 .utf8 AddCharset UTF-16 .utf16 AddCharset UTF-16BE .utf16be AddCharset UTF-16LE .utf16le AddCharset UTF-32 .utf32 AddCharset UTF-32BE .utf32be AddCharset UTF-32LE .utf32le AddCharset euc-cn .euc-cn AddCharset euc-gb .euc-gb AddCharset euc-jp .euc-jp AddCharset euc-kr .euc-kr #Not sure how euc-tw got in - IANA doesn't list it??? AddCharset EUC-TW .euc-tw AddCharset gb2312 .gb2312 .gb AddCharset iso-10646-ucs-2 .ucs-2 .iso-10646-ucs-2 AddCharset iso-10646-ucs-4 .ucs-4 .iso-10646-ucs-4 AddCharset shift_jis .shift_jis .sjis httpd-manual.conf †マニュアルディレクトリの設定。 通常Includeしないので省略。 httpd-mpm.conf †各MPMについての設定。 ここでPID設定だっけw <IfModule !mpm_netware_module> PidFile "logs/httpd.pid" </IfModule> # prefork MPM <IfModule mpm_prefork_module> StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxRequestWorkers 150 MaxConnectionsPerChild 0 </IfModule> # worker MPM <IfModule mpm_worker_module> StartServers 2 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestWorkers 150 MaxConnectionsPerChild 0 </IfModule> # event MPM <IfModule mpm_event_module> StartServers 2 起動時のプロセス数 MinSpareThreads 25 最低限確保するアイドルスレッド数 MaxSpareThreads 75 最大でもアイドルスレッドはこの数まで ThreadsPerChild 25 プロセスごとのスレッド数 MaxRequestWorkers 150 スレッド最大数=最大接続数 MaxConnectionsPerChild 0 子プロセスでさばく接続数。接続数に達したら子プロセスは死ぬ </IfModule> この設定だと子プロセスは最初は2、スレッドは2x25=50。 最大で子プロセスが6、スレッドは6x25=150。 ただしeventの場合、AsyncRequestWorkerFactor(規定値2)があるので 1プロセスあたり25ワーカースレッド+2スレッドの27スレッド。 たとえメモリリークが発生しても子プロセスは死なないので メモリ消費しまくり。 # NetWare MPM <IfModule mpm_netware_module> ThreadStackSize 65536 StartThreads 250 MinSpareThreads 25 MaxSpareThreads 250 MaxThreads 1000 MaxConnectionsPerChild 0 </IfModule> # OS/2 MPM <IfModule mpm_mpmt_os2_module> StartServers 2 MinSpareThreads 5 MaxSpareThreads 10 MaxConnectionsPerChild 0 </IfModule> # WinNT MPM <IfModule mpm_winnt_module> ThreadsPerChild 150 MaxConnectionsPerChild 0 </IfModule> free()が呼ばれるまで確保するメモリ量(kbyte)。規定値は無制限。 NetWare以外は <IfModule !mpm_netware_module> MaxMemFree 2048 </IfModule> NetWareは <IfModule mpm_netware_module> MaxMemFree 100 </IfModule> httpd-multilang-errordoc.conf †多言語対応エラーページ設定。 Alias /error/ "/usr/local/apache2/error/" <Directory "/usr/local/apache2/error"> AllowOverride None Options IncludesNoExec AddOutputFilter Includes html AddHandler type-map var Order allow,deny Allow from all LanguagePriority en cs de es fr it ja ko nl pl pt-br ro sv tr ForceLanguagePriority Prefer Fallback </Directory> ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var ErrorDocument 410 /error/HTTP_GONE.html.var ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var httpd-ssl.conf †HTTPS設定。 #SSLRandomSeed startup file:/dev/random 512 #SSLRandomSeed startup file:/dev/urandom 512 #SSLRandomSeed connect file:/dev/random 512 #SSLRandomSeed connect file:/dev/urandom 512 Listen 443 ## ## SSL Global Context ## SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 #SSLCipherSuite RC4-SHA:AES128-SHA:HIGH:MEDIUM:!aNULL:!MD5 #SSLHonorCipherOrder on SSLPassPhraseDialog builtin #SSLSessionCache "dbm:/usr/local/apache2/logs/ssl_scache" SSLSessionCache "shmcb:/usr/local/apache2/logs/ssl_scache(512000)" SSLSessionCacheTimeout 300 ## ## SSL Virtual Host Context ## <VirtualHost _default_:443> # General setup for the virtual host DocumentRoot "/usr/local/apache2/htdocs" ServerName www.example.com:443 ServerAdmin you@example.com ErrorLog "/usr/local/apache2/logs/error_log" TransferLog "/usr/local/apache2/logs/access_log" # SSL Engine Switch: # Enable/Disable SSL for this virtual host. SSLEngine on # Server Certificate: SSLCertificateFile "/usr/local/apache2/conf/server.crt" #SSLCertificateFile "/usr/local/apache2/conf/server-dsa.crt" #SSLCertificateFile "/usr/local/apache2/conf/server-ecc.crt" # Server Private Key: SSLCertificateKeyFile "/usr/local/apache2/conf/server.key" #SSLCertificateKeyFile "/usr/local/apache2/conf/server-dsa.key" #SSLCertificateKeyFile "/usr/local/apache2/conf/server-ecc.key" # Server Certificate Chain: #SSLCertificateChainFile "/usr/local/apache2/conf/server-ca.crt" # Certificate Authority (CA): #SSLCACertificatePath "/usr/local/apache2/conf/ssl.crt" #SSLCACertificateFile "/usr/local/apache2/conf/ssl.crt/ca-bundle.crt" # Certificate Revocation Lists (CRL): #SSLCARevocationPath "/usr/local/apache2/conf/ssl.crl" #SSLCARevocationFile "/usr/local/apache2/conf/ssl.crl/ca-bundle.crl" #SSLCARevocationCheck chain # Client Authentication (Type): #SSLVerifyClient require #SSLVerifyDepth 10 #<Location /> #SSLRequire ( %{SSL_CIPHER} !~ m/^(EXP|NULL)/ \ # and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \ # and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \ # and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \ # and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20 ) \ # or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/ #</Location> #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory "/usr/local/apache2/cgi-bin"> SSLOptions +StdEnvVars </Directory> BrowserMatch "MSIE [2-5]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog "/usr/local/apache2/logs/ssl_request_log" \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" </VirtualHost> httpd-userdir.conf †ユーザディレクトリの設定。 # Required module: mod_authz_core, mod_authz_host, mod_userdir UserDir public_html OrderからRequireになって少しすっきりしている。 <Directory "/home/*/public_html"> AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require method GET POST OPTIONS </Directory> httpd-vhosts.conf †バーチャルホスト設定。 NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin webmaster@example.jp DocumentRoot "/usr/local/apache2/htdocs" ServerName www.example.jp ServerAlias www.example.jp ErrorLog "logs/error_log" CustomLog "logs/access_log" combined </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@example.jp DocumentRoot "/usr/local/apache2/htdocs/another" ServerName another.example.jp ErrorLog "logs/another_error_log" CustomLog "logs/another_access_log" combined </VirtualHost> proxy-html.conf †何か増えてる( ´ω`) # 設定例. # # まず前提となるモジュールをロードしますよ。 # 註:mod_xml2encは必須ではないけども、使わなかったら # mod_proxy_htmlはASCIIかUnicode(UTF-8)以外のページを台無しにするかもよ。 # # Unix系の場合: # LoadFile /usr/lib/libxml2.so # LoadModule proxy_html_module modules/mod_proxy_html.so # LoadModule xml2enc_module modules/mod_xml2enc.so # # Windowsの場合 (標準的なライブラリの場所は知らん) # LoadFile C:/path/zlib.dll # LoadFile C:/path/iconv.dll # LoadFile C:/path/libxml2.dll # LoadModule proxy_html_module modules/mod_proxy_html.so # LoadModule xml2enc_module modules/mod_xml2enc.so # # HTMLのリンクに関するものはmod_proxy_htmlのコードからすべて削除されました。 # なので代わりに必ず自分で定義して、httpd.conf(か、Includeファイル)で読み込ませます。 # 普通はトップレベルに書きますが、<Location>の中でもよいです。 # # 以下、 W3C HTML 4.01 と XHTML 1.0 での定義です。 ProxyHTMLLinks a href ProxyHTMLLinks area href ProxyHTMLLinks link href ProxyHTMLLinks img src longdesc usemap ProxyHTMLLinks object classid codebase data usemap ProxyHTMLLinks q cite ProxyHTMLLinks blockquote cite ProxyHTMLLinks ins cite ProxyHTMLLinks del cite ProxyHTMLLinks form action ProxyHTMLLinks input src usemap ProxyHTMLLinks head profile ProxyHTMLLinks base href ProxyHTMLLinks script src for # JavaScriptなどのスクリプトでのイベントをサポートする(ProxyHTMLExtended On)場合、 # 同様に必ずイベントを定義します。 ProxyHTMLEvents onclick ondblclick onmousedown onmouseup \ onmouseover onmousemove onmouseout onkeypress \ onkeydown onkeyup onfocus onblur onload \ onunload onsubmit onreset onselect onchange # 過去の(1998以前、つまり"transitional") HTML or XHTMLを使いたいなら # 以下のリンクに関連する非推奨属性をアンコメントする必要があります。 # 早期のmod_proxy_htmlでは有効になっているので注意です。 # # ProxyHTMLLinks frame src longdesc # ProxyHTMLLinks iframe src longdesc # ProxyHTMLLinks body background # ProxyHTMLLinks applet codebase # # もし独自の属性を使っているのなら、適宜定義します。 # # ProxyHTMLLinks myelement myattr otherattr # ########### # 例! # ########### # # モジュールをロードしたあと # プライベートネットワーク上のアプリケーションサーバーのURL # http://some.app.intranet/のゲートウェイとして # /my-gateway/を定義したファイルをIncludeします。 # # ProxyRequests Off <-- セキュリティとして重要 # ProxyPass /my-gateway/ http://some.app.intranet/ # <Location /my-gateway/> # ProxyPassReverse / # ProxyHTMLEnable On # ProxyHTMLURLMap http://some.app.intranet/ /my-gateway/ # ProxyHTMLURLMap / /my-gateway/ # </Location> # # 実際は(全部じゃないけど)もちょっと複雑でしょう。 # # ドキュメントは # http://apache.webthing.com/mod_proxy_html/ # チュートリアルは # http://www.apachetutor.org/admin/reverseproxies |