亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

directory search
首頁(yè) 版本說(shuō)明 從1.3升級(jí)到2.0 編譯時(shí)配置的改變 運(yùn)行時(shí)配置的改變 雜項(xiàng)變化 第三方模塊 從 2.0 升級(jí)到 2.2 編譯時(shí)配置的改變 運(yùn)行時(shí)配置的改變 雜項(xiàng)變化 第三方模塊 Apache 2.1/2.2 版本的新特性 核心增強(qiáng) 模塊增強(qiáng) 程序增強(qiáng) 針對(duì)模塊開(kāi)發(fā)者的變化 Apache 2.0 版本的新特性 核心的增強(qiáng) 模塊的增強(qiáng) Apache許可證 參考手冊(cè) 編譯與安裝 針對(duì)心急者的概述 要求 下載 解壓 配置源代碼樹(shù) 編譯 安裝 配置 測(cè)試 升級(jí) 啟動(dòng) Apache是怎樣啟動(dòng)的 啟動(dòng)時(shí)發(fā)生錯(cuò)誤 隨系統(tǒng)啟動(dòng)時(shí)啟動(dòng) 額外信息 停止與重新啟動(dòng) 簡(jiǎn)介 立即停止 優(yōu)雅重啟 立即重啟 優(yōu)雅停止 附錄:信號(hào)和競(jìng)爭(zhēng)條件 運(yùn)行時(shí)配置指令 主配置文件 配置文件的語(yǔ)法 模塊 指令的作用域 .htaccess文件 配置段 配置段(容器)的類(lèi)型 文件系統(tǒng)和網(wǎng)絡(luò)空間 虛擬主機(jī) 代理 允許使用哪些指令? 配置段的合并 內(nèi)容緩沖 簡(jiǎn)介 緩沖概述 安全方面的考慮 文件句柄緩沖 內(nèi)存緩沖 磁盤(pán)緩沖 服務(wù)器全局配置 服務(wù)器標(biāo)識(shí) 文件定位 限制資源的使用 日志文件 安全警告 錯(cuò)誤日志 訪問(wèn)日志 日志滾動(dòng) 管道日志 虛擬主機(jī) 其他日志文件 從URL到文件系統(tǒng)的映射 相關(guān)模塊和指令 DocumentRoot DocumentRoot以外的文件 用戶(hù)目錄 URL重定向 反向代理 重寫(xiě)引擎 File Not Found 安全方面的提示 保持不斷更新和升級(jí) ServerRoot目錄的權(quán)限 服務(wù)器端包含 關(guān)于CGI 未指定為腳本的CGI 指定為腳本的CGI 其他動(dòng)態(tài)內(nèi)容的來(lái)源 系統(tǒng)設(shè)置的保護(hù) 默認(rèn)配置下服務(wù)器文件的保護(hù) 觀察日志文件 動(dòng)態(tài)共享對(duì)象(DSO) 實(shí)現(xiàn) 用法概要 背景知識(shí) 優(yōu)點(diǎn)和缺點(diǎn) 內(nèi)容協(xié)商 關(guān)于內(nèi)容協(xié)商 Apache中的內(nèi)容協(xié)商 協(xié)商的方法 打亂品質(zhì)值 透明內(nèi)容協(xié)商的擴(kuò)展 超鏈和名稱(chēng)轉(zhuǎn)換說(shuō)明 緩沖說(shuō)明 更多信息 自定義錯(cuò)誤響應(yīng) 行為 配置 自定義錯(cuò)誤響應(yīng)與重定向 地址和端口綁定 概述 針對(duì)IPv6的特殊考慮 怎樣與虛擬主機(jī)協(xié)同工作 多路處理模塊(MPM) 簡(jiǎn)介 選擇一個(gè)MPM 默認(rèn)的MPM 環(huán)境變量 設(shè)置環(huán)境變量 使用環(huán)境變量 用于特殊目的的環(huán)境變量 示例 處理器的使用 什么是處理器? 例子 程序員注意事項(xiàng) 過(guò)濾器 Apache2中的過(guò)濾器 智能過(guò)慮 使用過(guò)濾器 CGI腳本的Suexec執(zhí)行 開(kāi)始之前 suEXEC的安全模型 配置和安裝suEXEC 啟用和禁用suEXEC 使用suEXEC 調(diào)試suEXEC 謹(jǐn)防Jabberwock:警告和舉例 性能調(diào)整 硬件和操作系統(tǒng) 運(yùn)行時(shí)的配置 編譯時(shí)的配置 附錄:蹤跡的詳細(xì)分析 URL重寫(xiě)指南 mod_rewrite簡(jiǎn)介 實(shí)踐方案 URL的規(guī)劃 內(nèi)容的處理 對(duì)訪問(wèn)的限制 其他 虛擬主機(jī)文檔 總述 虛擬主機(jī)支持 配置指令 基于主機(jī)名的虛擬主機(jī) 基于域名的虛擬主機(jī)和基于IP的虛擬主機(jī)比較 使用基于域名的虛擬主機(jī) 與舊版瀏覽器的兼容性 基于IP地址的虛擬主機(jī) 系統(tǒng)需求 如何配置Apache 設(shè)置多個(gè)守護(hù)進(jìn)程 配置擁有多個(gè)虛擬主機(jī)的單一守護(hù)進(jìn)程 動(dòng)態(tài)配置大量虛擬主機(jī) 動(dòng)機(jī) 概述 簡(jiǎn)單的動(dòng)態(tài)虛擬主機(jī) 一個(gè)實(shí)際的個(gè)人主頁(yè)系統(tǒng) 在同一個(gè)服務(wù)器上架設(shè)多個(gè)主機(jī)的虛擬系統(tǒng) 更為有效的基于IP地址的虛擬主機(jī) 使用老版本的Apache 使用mod_rewrite實(shí)現(xiàn)簡(jiǎn)單的動(dòng)態(tài)虛擬主機(jī) 使用mod_rewrite的個(gè)人主頁(yè)系統(tǒng) 使用獨(dú)立的虛擬主機(jī)配置文件 虛擬主機(jī)的普通配置示例 在一個(gè)IP地址上運(yùn)行多個(gè)基于域名的web站點(diǎn) 在多于一個(gè)IP的情況下使用基于域名的虛擬主機(jī) 在不同的IP的地址(比如一個(gè)內(nèi)部和一個(gè)外部地址)上提供相同的內(nèi)容 在不同的端口上運(yùn)行不同的站點(diǎn) 建立基于IP的虛擬主機(jī) 混用基于端口和基于IP的虛擬主機(jī) 混用基于域名和基于IP的虛擬主機(jī) 將虛擬主機(jī)和代理模塊一起使用 使用默認(rèn)虛擬主機(jī) 將一個(gè)基于域名的虛擬主機(jī)移植為一個(gè)基于IP的虛擬主機(jī) 使用ServerPath指令 深入討論虛擬主機(jī)的匹配 解析配置文件 虛擬主機(jī)匹配 小技巧 文件描述符限制 關(guān)于DNS和Apache 一個(gè)簡(jiǎn)單示例 拒絕服務(wù) "主服務(wù)器"地址 避免這些問(wèn)題的小技巧 附錄:進(jìn)一步的提示 常見(jiàn)問(wèn)題 概述 SSL/TLS 加密 概述 文檔 mod_ssl 緒論 密碼技術(shù) 證書(shū) 安全套接字層(SSL) 參考 兼容性 配置指令 環(huán)境變量 自定義日志功能 如何... 加密方案和強(qiáng)制性高等級(jí)安全 客戶(hù)認(rèn)證和訪問(wèn)控制 常見(jiàn)問(wèn)題解答 About The Module Installation Configuration Certificates The SSL Protocol mod_ssl Support 如何.../指南 概述 認(rèn)證 相關(guān)模塊和指令 簡(jiǎn)介 先決條件 啟用認(rèn)證 允許多人訪問(wèn) 可能存在的問(wèn)題 其他認(rèn)證方法 更多信息 CGI動(dòng)態(tài)頁(yè)面 簡(jiǎn)介 配置Apache以允許CGI 編寫(xiě)CGI程序 程序還是不能運(yùn)行! 幕后是怎樣操作的? CGI模塊/庫(kù) 更多信息 服務(wù)器端包含 簡(jiǎn)介 什么是SSI? 配置服務(wù)器以允許SSI 基本SSI指令 附加的例子 我還能設(shè)置其它什么? 執(zhí)行命令 高級(jí)SSI技術(shù) 總結(jié) .htaccess文件 .htaccess文件 工作原理和使用方法 (不)使用.htaccess文件的場(chǎng)合 指令的生效 認(rèn)證舉例 服務(wù)器端包含(SSI)舉例 CGI舉例 疑難解答 用戶(hù)網(wǎng)站目錄 用戶(hù)網(wǎng)站目錄 用UserDir設(shè)置文件路徑 限定哪些用戶(hù)可以使用此功能 啟用對(duì)每個(gè)用戶(hù)都有效的cgi目錄 允許用戶(hù)改變配置 對(duì)特定平臺(tái)的說(shuō)明 概述 Microsoft Windows 其他平臺(tái) 在Microsoft Windows中使用Apache 對(duì)操作系統(tǒng)的要求 下載 Apache for Windows 安裝 Apache for Windows 配置 Apache for Windows 以服務(wù)方式運(yùn)行 Apache for Windows 作為控制臺(tái)程序運(yùn)行Apache 測(cè)試安裝 編譯Windows下的Apache 系統(tǒng)要求 命令行編譯 Developer Studio集成開(kāi)發(fā)環(huán)境的工作區(qū)編譯 項(xiàng)目組件 在Novell NetWare平臺(tái)上使用Apache Requirements Downloading Apache for NetWare Installing Apache for NetWare Running Apache for NetWare Configuring Apache for NetWare Compiling Apache for NetWare 在HP-UX中運(yùn)行Apache The Apache EBCDIC Port Overview of the Apache EBCDIC Port Design Goals Technical Solution Porting Notes Document Storage Notes Apache Modules' Status Third Party Modules' Status 服務(wù)器與支持程序 概述 httpd 語(yǔ)法 選項(xiàng) ab 語(yǔ)法 選項(xiàng) Bugs apachectl 語(yǔ)法 選項(xiàng) apxs 語(yǔ)法 選項(xiàng) 舉例 configure 語(yǔ)法 選項(xiàng) 環(huán)境變量 dbmmanage 語(yǔ)法 選項(xiàng) Bugs htcacheclean 語(yǔ)法 選項(xiàng) 返回值 htdbm 語(yǔ)法 選項(xiàng) Bugs 返回值 舉例 安全方面的考慮 限制 htdigest 語(yǔ)法 選項(xiàng) htpasswd 語(yǔ)法 選項(xiàng) 返回值 舉例 安全方面的考慮 限制 logresolve 語(yǔ)法 選項(xiàng) rotatelogs 語(yǔ)法 選項(xiàng) Portability suexec 語(yǔ)法 選項(xiàng) 其他程序 log_server_status split-logfile 雜項(xiàng)文檔 概述 相關(guān)標(biāo)準(zhǔn) HTTP推薦標(biāo)準(zhǔn) HTML推薦標(biāo)準(zhǔn) 認(rèn)證 語(yǔ)言/國(guó)家代碼 Apache 模塊 描述模塊的術(shù)語(yǔ) 說(shuō)明 狀態(tài) 源代碼文件 模塊標(biāo)識(shí)符 兼容性 描述指令的術(shù)語(yǔ) 說(shuō)明 語(yǔ)法 默認(rèn)值(Default) 作用域(Context) 覆蓋項(xiàng)(Override) 狀態(tài) 模塊(Module) 兼容性(Compatibility) Apache核心(Core)特性 AcceptFilter AcceptPathInfo AccessFileName AddDefaultCharset AddOutputFilterByType AllowEncodedSlashes AllowOverride AuthName AuthType CGIMapExtension ContentDigest DefaultType <Directory> <DirectoryMatch> DocumentRoot EnableMMAP EnableSendfile ErrorDocument ErrorLog FileETag <Files> <FilesMatch> ForceType HostnameLookups <IfDefine> <IfModule> Include KeepAlive KeepAliveTimeout <Limit> <LimitExcept> LimitInternalRecursion LimitRequestBody LimitRequestFields LimitRequestFieldSize LimitRequestLine LimitXMLRequestBody <Location> <LocationMatch> LogLevel MaxKeepAliveRequests NameVirtualHost Options Require RLimitCPU RLimitMEM RLimitNPROC Satisfy ScriptInterpreterSource ServerAdmin ServerAlias ServerName ServerPath ServerRoot ServerSignature ServerTokens SetHandler SetInputFilter SetOutputFilter TimeOut TraceEnable UseCanonicalName UseCanonicalPhysicalPort <VirtualHost> Apache MPM 公共指令 AcceptMutex CoreDumpDirectory EnableExceptionHook GracefulShutdownTimeout Group Listen ListenBackLog LockFile MaxClients MaxMemFree MaxRequestsPerChild MaxSpareThreads MinSpareThreads PidFile ReceiveBufferSize ScoreBoardFile SendBufferSize ServerLimit StartServers StartThreads ThreadLimit ThreadsPerChild ThreadStackSize User Apache MPM beos MaxRequestsPerThread CoreDumpDirectory Group Listen ListenBacklog MaxClients MaxMemFree MaxSpareThreads MinSpareThreads PidFile ReceiveBufferSize ScoreBoardFile SendBufferSize StartThreads User Apache MPM event AcceptMutex CoreDumpDirectory EnableExceptionHook Group Listen ListenBacklog LockFile MaxClients MaxMemFree MaxRequestsPerChild MaxSpareThreads MinSpareThreads PidFile ScoreBoardFile SendBufferSize ServerLimit StartServers ThreadLimit ThreadsPerChild ThreadStackSize User Apache MPM netware MaxThreads Listen ListenBacklog MaxMemFree MaxRequestsPerChild MaxSpareThreads MinSpareThreads ReceiveBufferSize SendBufferSize StartThreads ThreadStackSize Apache MPM os2 Group Listen ListenBacklog MaxRequestsPerChild MaxSpareThreads MinSpareThreads PidFile ReceiveBufferSize SendBufferSize StartServers User Apache MPM prefork 工作方式 MaxSpareServers MinSpareServers AcceptMutex CoreDumpDirectory EnableExceptionHook Group Listen ListenBacklog LockFile MaxClients MaxMemFree MaxRequestsPerChild PidFile ReceiveBufferSize ScoreBoardFile SendBufferSize ServerLimit StartServers User Apache MPM winnt Win32DisableAcceptEx CoreDumpDirectory Listen ListenBacklog MaxMemFree MaxRequestsPerChild PidFile ReceiveBufferSize ScoreBoardFile SendBufferSize ThreadLimit ThreadsPerChild ThreadStackSize Apache MPM worker 工作方式 AcceptMutex CoreDumpDirectory EnableExceptionHook Group Listen ListenBacklog LockFile MaxClients MaxMemFree MaxRequestsPerChild MaxSpareThreads MinSpareThreads PidFile ReceiveBufferSize ScoreBoardFile SendBufferSize ServerLimit StartServers ThreadLimit ThreadsPerChild ThreadStackSize User Apache Module mod_actions Action指令 Script指令 Apache Module mod_alias 處理順序 Alias AliasMatch Redirect RedirectMatch RedirectPermanent RedirectTemp ScriptAlias ScriptAliasMatch Apache Module mod_asis 用法 Apache Module mod_auth_basic AuthBasicAuthoritative AuthBasicProvider Apache Module mod_auth_digest 使用摘要認(rèn)證 配合 MS Internet Explorer 6 工作 AuthDigestAlgorithm AuthDigestDomain AuthDigestNcCheck AuthDigestNonceFormat AuthDigestNonceLifetime AuthDigestProvider AuthDigestQop AuthDigestShmemSize Apache Module mod_authn_alias 示例 <AuthnProviderAlias> Apache Module mod_authn_anon 示例 Anonymous Anonymous_LogEmail Anonymous_MustGiveEmail Anonymous_NoUserID Anonymous_VerifyEmail Apache Module mod_authn_dbd 配置示例 AuthDBDUserPWQuery AuthDBDUserRealmQuery Apache Module mod_authn_dbm AuthDBMType AuthDBMUserFile Apache Module mod_authn_default AuthDefaultAuthoritative Apache Module mod_authn_file AuthUserFile Apache Module mod_authnz_ldap Contents Operation The require Directives 舉例 Using TLS Using SSL Using Microsoft FrontPage with mod_authnz_ldap AuthLDAPBindDN AuthLDAPBindPassword AuthLDAPCharsetConfig AuthLDAPCompareDNOnServer AuthLDAPDereferenceAliases AuthLDAPGroupAttribute AuthLDAPGroupAttributeIsDN AuthLDAPRemoteUserIsDN AuthLDAPUrl AuthzLDAPAuthoritative Apache Module mod_authz_dbm AuthDBMGroupFile AuthzDBMAuthoritative AuthzDBMType Apache Module mod_authz_default AuthzDefaultAuthoritative Apache Module mod_authz_groupfile AuthGroupFile AuthzGroupFileAuthoritative Apache Module mod_authz_host Allow Deny Order Apache Module mod_authz_owner 配置示例 AuthzOwnerAuthoritative Apache Module mod_authz_user AuthzUserAuthoritative Apache Module mod_autoindex Autoindex Request Query Arguments AddAlt AddAltByEncoding AddAltByType AddDescription AddIcon AddIconByEncoding AddIconByType DefaultIcon HeaderName IndexIgnore IndexOptions IndexOrderDefault IndexStyleSheet ReadmeName Apache Module mod_cache Related Modules and Directives 配置示例 CacheDefaultExpire CacheDisable CacheEnable CacheIgnoreCacheControl CacheIgnoreHeaders CacheIgnoreNoLastMod CacheLastModifiedFactor CacheMaxExpire CacheStoreNoStore CacheStorePrivate Apache Module mod_cern_meta MetaDir MetaFiles MetaSuffix Apache Module mod_cgi CGI 環(huán)境變量 CGI 腳本的調(diào)試 ScriptLog ScriptLogBuffer ScriptLogLength Apache Module mod_cgid ScriptSock ScriptLog ScriptLogBuffer ScriptLogLength Apache Module mod_charset_lite Common Problems CharsetDefault CharsetOptions CharsetSourceEnc Apache Module mod_dav Enabling WebDAV Security Issues Complex Configurations Dav DavDepthInfinity DavMinTimeout Apache Module mod_dav_fs DavLockDB Apache Module mod_dav_lock DavGenericLockDB Apache Module mod_dbd Connection Pooling Apache DBD API SQL Prepared Statements DBDExptime DBDKeep DBDMax DBDMin DBDParams DBDPersist DBDPrepareSQL DBDriver Apache Module mod_deflate 配置舉例 啟用壓縮 代理服務(wù)器 DeflateBufferSize DeflateCompressionLevel DeflateFilterNote DeflateMemLevel DeflateWindowSize Apache Module mod_dir DirectoryIndex DirectorySlash Apache Module mod_disk_cache CacheDirLength CacheDirLevels CacheMaxFileSize CacheMinFileSize CacheRoot Apache Module mod_dumpio 啟用dumpio支持 DumpIOInput DumpIOOutput Apache Module mod_echo ProtocolEcho Apache Module mod_env PassEnv SetEnv UnsetEnv Apache Module mod_example Compiling the example module Using the mod_example Module Example Apache Module mod_expires 交替間隔語(yǔ)法 ExpiresActive ExpiresByType ExpiresDefault Apache Module mod_ext_filter 舉例 ExtFilterDefine ExtFilterOptions Apache Module mod_file_cache Using mod_file_cache CacheFile MMapFile Apache Module mod_filter Smart Filtering Filter Declarations Configuring the Chain Examples Protocol Handling FilterChain FilterDeclare FilterProtocol FilterProvider FilterTrace Apache Module mod_headers 處理順序 前處理和后處理 舉例 Header RequestHeader Apache Module mod_ident IdentityCheck IdentityCheckTimeout Apache Module mod_imagemap New Features Imagemap File Example Mapfile Referencing your mapfile ImapBase ImapDefault ImapMenu Apache Module mod_include Enabling Server-Side Includes PATH_INFO with Server Side Includes Basic Elements Include Variables Variable Substitution Flow Control Elements SSIEndTag SSIErrorMsg SSIStartTag SSITimeFormat SSIUndefinedEcho XBitHack Apache Module mod_info 安全問(wèn)題 選擇哪些信息可以被顯示 已知的局限 AddModuleInfo Apache Module mod_isapi 用法 附加注釋 程序員注記 ISAPIAppendLogToErrors ISAPIAppendLogToQuery ISAPICacheFile ISAPIFakeAsync ISAPILogNotSupported ISAPIReadAheadBuffer Apache Module mod_ldap 示例配置 LDAP 連接池 LDAP 緩沖 使用SSL/TLS SSL/TLS 證書(shū) LDAPCacheEntries LDAPCacheTTL LDAPConnectionTimeout LDAPOpCacheEntries LDAPOpCacheTTL LDAPSharedCacheFile LDAPSharedCacheSize LDAPTrustedClientCert LDAPTrustedGlobalCert LDAPTrustedMode LDAPVerifyServerCert Apache Module mod_log_config 定制日志文件格式 安全考慮 BufferedLogs CookieLog CustomLog LogFormat TransferLog Apache Module mod_log_forensic 定制日志文件格式 安全考慮 ForensicLog Apache Module mod_logio 定制日志文件格式 Apache Module mod_mem_cache MCacheMaxObjectCount MCacheMaxObjectSize MCacheMaxStreamingBuffer MCacheMinObjectSize MCacheRemovalAlgorithm MCacheSize Apache Module mod_mime 帶多擴(kuò)展名的文件 內(nèi)容編碼 字符集和語(yǔ)言 AddCharset AddEncoding AddHandler AddInputFilter AddLanguage AddOutputFilter AddType DefaultLanguage ModMimeUsePathInfo MultiviewsMatch RemoveCharset RemoveEncoding RemoveHandler RemoveInputFilter RemoveLanguage RemoveOutputFilter RemoveType TypesConfig Apache Module mod_mime_magic "Magic文件"的格式 性能問(wèn)題 注意 MimeMagicFile Apache Module mod_negotiation 類(lèi)型表 MultiViews CacheNegotiatedDocs ForceLanguagePriority LanguagePriority Apache Module mod_nw_ssl NWSSLTrustedCerts NWSSLUpgradeable SecureListen Apache Module mod_proxy 正向和反向代理 簡(jiǎn)單示例 控制對(duì)代理服務(wù)器的訪問(wèn) 緩慢啟動(dòng) 局域網(wǎng)代理 協(xié)議調(diào)整 請(qǐng)求體 AllowCONNECT NoProxy <Proxy> ProxyBadHeader ProxyBlock ProxyDomain ProxyErrorOverride ProxyIOBufferSize <ProxyMatch> ProxyMaxForwards ProxyPass ProxyPassReverse ProxyPassReverseCookieDomain ProxyPassReverseCookiePath ProxyPreserveHost ProxyReceiveBufferSize ProxyRemote ProxyRemoteMatch ProxyRequests ProxyTimeout ProxyVia Apache Module mod_proxy_ajp Overview of the protocol Basic Packet Structure Request Packet Structure Response Packet Structure Apache Module mod_proxy_balancer Load balancer scheduler algorithm Request Counting Algorithm Weighted Traffic Counting Algorithm Enabling Balancer Manager Support Apache Module mod_proxy_connect Apache Module mod_proxy_ftp 為什么xxx類(lèi)型的文件不能從FTP下載? 如何強(qiáng)制文件xxx使用FTP的ASCII形式下載? 我如何使用FTP上傳? 我如何能訪問(wèn)我自己home目錄以外的FTP文件? 我如何才能在瀏覽器的URL框中隱藏FTP的明文密碼? Apache Module mod_proxy_http Apache Module mod_rewrite 特殊字符的引用 環(huán)境變量 實(shí)用方案 RewriteBase RewriteCond RewriteEngine RewriteLock RewriteLog RewriteLogLevel RewriteMap RewriteOptions RewriteRule Apache Module mod_setenvif BrowserMatch BrowserMatchNoCase SetEnvIf SetEnvIfNoCase Apache Module mod_so 為Windows創(chuàng)建可加載模塊 LoadFile LoadModule Apache Module mod_speling CheckSpelling Apache Module mod_ssl 環(huán)境變量 Custom Log Formats SSLCACertificateFile SSLCACertificatePath SSLCADNRequestFile SSLCADNRequestPath SSLCARevocationFile SSLCARevocationPath SSLCertificateChainFile SSLCertificateFile SSLCertificateKeyFile SSLCipherSuite SSLCryptoDevice SSLEngine SSLHonorCipherOrder SSLMutex SSLOptions SSLPassPhraseDialog SSLProtocol SSLProxyCACertificateFile SSLProxyCACertificatePath SSLProxyCARevocationFile SSLProxyCARevocationPath SSLProxyCipherSuite SSLProxyEngine SSLProxyMachineCertificateFile SSLProxyMachineCertificatePath SSLProxyProtocol SSLProxyVerify SSLProxyVerifyDepth SSLRandomSeed SSLRequire SSLRequireSSL SSLSessionCache SSLSessionCacheTimeout SSLUserName SSLVerifyClient SSLVerifyDepth Apache Module mod_status Enabling Status Support 自動(dòng)更新 Machine Readable Status File ExtendedStatus Apache Module mod_suexec SuexecUserGroup Apache Module mod_unique_id Theory Apache Module mod_userdir UserDir Apache Module mod_usertrack Logging 2-digit or 4-digit dates for cookies? CookieDomain CookieExpires CookieName CookieStyle CookieTracking Apache Module mod_version <IfVersion> Apache Module mod_vhost_alias 目錄名稱(chēng)的轉(zhuǎn)換 示例 VirtualDocumentRoot VirtualDocumentRootIP VirtualScriptAlias VirtualScriptAliasIP 開(kāi)發(fā)者文檔 Overview Topics External Resources Apache API notes Basic concepts How handlers work Resource allocation and resource pools Configuration Debugging Memory Allocation in APR Available debugging options Allowable Combinations Activating Debugging Options Documenting Apache 2.0 Apache 2.0 Hook Functions Creating a hook function Hooking the hook Converting Modules from Apache 1.3 to Apache 2.0 The easier changes ... The messier changes... Request Processing in Apache 2.0 The Request Processing Cycle The Request Parsing Phase The Security Phase The Preparation Phase The Handler Phase How Filters Work in Apache 2.0 Filter Types How are filters inserted? Asis Explanations 詞匯和索引 詞匯表 模塊索引 指令索引 指令速查 譯者聲明
characters

Apache模塊 mod_proxy

說(shuō)明 提供HTTP/1.1的代理/網(wǎng)關(guān)功能支持
狀態(tài) 擴(kuò)展(E)
模塊名 proxy_module
源文件 mod_proxy.c

概述

警告

在您沒(méi)有對(duì)服務(wù)器采取安全措施之前,請(qǐng)不要用ProxyRequests啟用代理。一個(gè)開(kāi)放的代理服務(wù)器不僅對(duì)您的網(wǎng)絡(luò)有威脅,對(duì)整個(gè)因特網(wǎng)來(lái)說(shuō)也同樣如此。

此模塊實(shí)現(xiàn)了Apache的代理/網(wǎng)關(guān)。它實(shí)現(xiàn)了以下規(guī)范的代理:AJP13(Apache JServe Protocol v1.3), FTP, CONNECT(用于SSL), HTTP/0.9, HTTP/1.0, HTTP/1.1 。此模塊經(jīng)配置后可用上述或其它協(xié)議連接其它代理模塊。

Apache的代理功能(除mod_proxy以外)被劃分到了幾個(gè)不同的模塊中:mod_proxy_http, mod_proxy_ftp, mod_proxy_ajp, mod_proxy_balancer, mod_proxy_connect 。這樣,如果想使用一個(gè)或多個(gè)代理功能,就必須將mod_proxy對(duì)應(yīng)的模塊同時(shí)加載到服務(wù)器中(靜態(tài)連接或用LoadModule動(dòng)態(tài)加載)。

另外,其它模塊還提供了擴(kuò)展特性。mod_cache及其相關(guān)模塊提供了緩沖特性。mod_ssl提供的SSLProxy*系列指令可以使用SSL/TLS連接遠(yuǎn)程服務(wù)器。這些提供擴(kuò)展特性的模塊必須在被正確加載和配置以后才能提供這些擴(kuò)展功能。

正向和反向代理

Apache可以被配置為正向(forward)反向(reverse)代理。

正向代理是一個(gè)位于客戶(hù)端和原始服務(wù)器(origin server)之間的服務(wù)器,為了從原始服務(wù)器取得內(nèi)容,客戶(hù)端向代理發(fā)送一個(gè)請(qǐng)求并指定目標(biāo)(原始服務(wù)器),然后代理向原始服務(wù)器轉(zhuǎn)交請(qǐng)求并將獲得的內(nèi)容返回給客戶(hù)端??蛻?hù)端必須要進(jìn)行一些特別的設(shè)置才能使用正向代理。

正向代理的典型用途是為在防火墻內(nèi)的局域網(wǎng)客戶(hù)端提供訪問(wèn)Internet的途徑。正向代理還可以使用緩沖特性(由mod_cache提供)減少網(wǎng)絡(luò)使用率。

使用ProxyRequests指令即可激活正向代理。因?yàn)檎虼碓试S客戶(hù)端通過(guò)它訪問(wèn)任意網(wǎng)站并且隱藏客戶(hù)端自身,因此你必須采取安全措施以確保僅為經(jīng)過(guò)授權(quán)的客戶(hù)端提供服務(wù)。

反向代理正好相反,對(duì)于客戶(hù)端而言它就像是原始服務(wù)器,并且客戶(hù)端不需要進(jìn)行任何特別的設(shè)置??蛻?hù)端向反向代理的名字空間(name-space)中的內(nèi)容發(fā)送普通請(qǐng)求,接著反向代理將判斷向何處(原始服務(wù)器)轉(zhuǎn)交請(qǐng)求,并將獲得的內(nèi)容返回給客戶(hù)端,就像這些內(nèi)容原本就是它自己的一樣。

反向代理的典型用途是將防火墻后面的服務(wù)器提供給Internet用戶(hù)訪問(wèn)。反向代理還可以為后端的多臺(tái)服務(wù)器提供負(fù)載平衡,或?yàn)楹蠖溯^慢的服務(wù)器提供緩沖服務(wù)。另外,還可以啟用高級(jí)URL策略和管理技術(shù),從而使處于不同web服務(wù)器系統(tǒng)的web頁(yè)面同時(shí)存在于同一個(gè)URL空間下。

可以使用ProxyPass指令激活反向代理(在RewriteRule指令中使用[P]標(biāo)記也可以)。配置反向代理并不需要打開(kāi)ProxyRequests指令。

簡(jiǎn)單示例

下面的例子僅僅是為了給你一個(gè)基本概念而幫助入門(mén)而已,請(qǐng)仔細(xì)閱讀每個(gè)指令的文檔。

另外,如果想使用緩沖特性,請(qǐng)查看mod_cache文檔。

正向代理

ProxyRequests On
ProxyVia On

<Proxy *>
Order deny,allow
Deny from all
Allow from internal.example.com
</Proxy>

反向代理

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass /foo http://foo.example.com/bar
ProxyPassReverse /foo http://foo.example.com/bar

控制對(duì)代理服務(wù)器的訪問(wèn)

您可以通過(guò)<Proxy>的阻止功能來(lái)控制誰(shuí)能訪問(wèn)您的代理。示例如下:

<Proxy *>
Order Deny,Allow
Deny from all
Allow from 192.168.0
</Proxy>

要了解更多訪問(wèn)控制信息,請(qǐng)參見(jiàn)mod_authz_host文檔。

使用正向代理時(shí)嚴(yán)格控制訪問(wèn)權(quán)限(使用ProxyRequests指令)是非常重要的。否則你的代理會(huì)被客戶(hù)端利用來(lái)訪問(wèn)其它服務(wù)器并且隱藏客戶(hù)端的真實(shí)身份。這不僅對(duì)您的網(wǎng)絡(luò)有威脅,對(duì)整個(gè)因特網(wǎng)來(lái)說(shuō)也同樣如此。當(dāng)使用反向代理(在"ProxyRequests Off"條件下使用ProxyPass指令)的時(shí)候訪問(wèn)控制要相對(duì)寬松,因?yàn)榭蛻?hù)端只能連接你配置的特定主機(jī)。

緩慢啟動(dòng)

如果您使用了ProxyBlock指令,將會(huì)在啟動(dòng)時(shí)查找并緩存主機(jī)名的IP地址以備后繼的匹配測(cè)試使用。這將會(huì)花費(fèi)幾秒或更長(zhǎng)的時(shí)間,這主要取決于主機(jī)名查找的速度。

局域網(wǎng)代理

位于局域網(wǎng)內(nèi)的Apache代理服務(wù)器需要經(jīng)由公司的防火墻轉(zhuǎn)發(fā)對(duì)外部的請(qǐng)求(使用ProxyRemote指令來(lái)配置)。但當(dāng)它訪問(wèn)局域網(wǎng)內(nèi)的資源時(shí),它能越過(guò)防火墻直接訪問(wèn)目的主機(jī)。在訪問(wèn)一個(gè)屬于局域網(wǎng)的服務(wù)器從而進(jìn)行直接連接時(shí),NoProxy指令就會(huì)很有用。

局域網(wǎng)內(nèi)的用戶(hù)習(xí)慣于不在他們的WWW請(qǐng)求中加入本地域的名稱(chēng),于是會(huì)使用"http://somehost/"來(lái)取代http://somehost.example.com/ 。一些商業(yè)代理服務(wù)器會(huì)不管這些,只是采用本地域的配置來(lái)簡(jiǎn)單的伺服這個(gè)請(qǐng)求。當(dāng)使用了ProxyDomain指令來(lái)為服務(wù)器配置了一個(gè)代理服務(wù)時(shí),Apache會(huì)發(fā)出一個(gè)重定向應(yīng)答,以使客戶(hù)端請(qǐng)求到達(dá)正確的、能滿(mǎn)足要求的服務(wù)器地址。因?yàn)檫@樣一來(lái),用戶(hù)的書(shū)簽文件就會(huì)隨之包含完整的主機(jī)名,所以這是首選的方法。

協(xié)議調(diào)整

當(dāng)mod_proxy向一個(gè)沒(méi)有正確實(shí)現(xiàn)持久連接(KeepAlive)或HTTP/1.1的原始服務(wù)器發(fā)送請(qǐng)求的時(shí)候,可以通過(guò)設(shè)置兩個(gè)環(huán)境變量來(lái)發(fā)送不帶持久連接(KeepAlive)的HTTP/1.0請(qǐng)求。這兩個(gè)變量是通過(guò)SetEnv指令設(shè)置的。

以下是force-proxy-request-1.0proxy-nokeepalive的例子:

<Location /buggyappserver/>
ProxyPass http://buggyappserver:7001/foo/
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
</Location>

請(qǐng)求體

一些請(qǐng)求方法(如POST)包含一個(gè)請(qǐng)求體。HTTP協(xié)議要求包含請(qǐng)求體的請(qǐng)求或者使用塊傳輸編碼(chunked transfer encoding)或者包含一個(gè)Content-Length請(qǐng)求頭。當(dāng)將這種請(qǐng)求傳遞給原始服務(wù)器的時(shí)候,mod_proxy_http會(huì)始終嘗試使用Content-Length請(qǐng)求頭。但如果原始請(qǐng)求使用的是塊編碼,那么塊編碼也同樣可以用于上行請(qǐng)求??梢允褂铆h(huán)境變量控制這種選擇。設(shè)置proxy-sendcl可以確保始終發(fā)送Content-Length頭以與上游服務(wù)器保持最大程度的兼容性,而設(shè)置proxy-sendchunked可以通過(guò)繼續(xù)使用塊編碼以盡可能最小化資源占用率。

AllowCONNECT 指令

說(shuō)明 通過(guò)代理允許CONNECT的端口號(hào)
語(yǔ)法 AllowCONNECT port [port] ...
默認(rèn)值 AllowCONNECT 443 563
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

AllowCONNECT指令指定了此代理的CONNECT方法可以連接的端口號(hào)列表。當(dāng)今的瀏覽器在進(jìn)行https連接請(qǐng)求時(shí)使用這種方法,而代理默認(rèn)會(huì)將其轉(zhuǎn)為http。

默認(rèn)只啟用了默認(rèn)的https端口(443)和默認(rèn)的snews端口(563)。使用AllowCONNECT指令可以覆蓋默認(rèn)設(shè)置而改為僅允許連接列出的端口。

注意,必須確保mod_proxy_connect也同時(shí)存在于服務(wù)器中,這樣才能支持CONNECT 。

NoProxy 指令

說(shuō)明 直接進(jìn)行連接的主機(jī)/域/網(wǎng)絡(luò)
語(yǔ)法 NoProxy host [host] ...
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

此指令僅適用于局域網(wǎng)內(nèi)的Apache代理服務(wù)器。NoProxy指令指定了一個(gè)中間以空格分隔的子網(wǎng)、IP地址、主機(jī)和/或域的列表。對(duì)某個(gè)匹配上述一個(gè)或多個(gè)列表項(xiàng)的主機(jī)的請(qǐng)求將直接被其伺服而不會(huì)轉(zhuǎn)交到配置好的ProxyRemote代理服務(wù)器。

示例

ProxyRemote * http://firewall.mycompany.com:81
NoProxy .mycompany.com 192.168.112.0/21

NoProxy指令的host參數(shù)可以是以下選項(xiàng)之一:

是一個(gè)DNS域名的一部分,并在前面加上點(diǎn)號(hào)。它表示一批邏輯上屬于同一個(gè)DNS區(qū)域的主機(jī),也就是所有這些主機(jī)名具有相同的后綴,而這個(gè)"后綴"就是

例子

.com
.apache.org.

主機(jī)名(一個(gè)DNS域甚至也可能有一條DNS"A記錄"!)的不同之處在于始終有一個(gè)前導(dǎo)點(diǎn)。

注意

域名不區(qū)分大小寫(xiě)并且始終認(rèn)為是錨定在DNS樹(shù)根上的,因此.MyDomain.com.mydomain.com.(注意結(jié)尾點(diǎn)號(hào))是完全等同的。因?yàn)橛虻谋容^不需要進(jìn)行DNS查詢(xún),因此它比子網(wǎng)比較更加高效。

子網(wǎng)

子網(wǎng)以點(diǎn)分十進(jìn)制形式表示了一個(gè)因特網(wǎng)地址的一部分,有時(shí)會(huì)跟著一個(gè)斜杠和子網(wǎng)掩碼,以指定子網(wǎng)中的有效bit位。它用于表示主機(jī)通過(guò)自身的普通網(wǎng)絡(luò)接口可以訪問(wèn)的子網(wǎng)范圍。未指定子網(wǎng)掩碼的時(shí)候就假定忽略掉的(或?yàn)榱愕?結(jié)尾數(shù)字就是掩碼,在這種情況下,掩碼bit長(zhǎng)度必須是8bit的整數(shù)倍。例如:

192.168192.168.0.0
子網(wǎng)"192.168.0.0"表示掩碼為16bit(有時(shí)也用255.255.0.0表示)。
192.168.112.0/21
子網(wǎng)"192.168.112.0/21"表示掩碼為21bit(有時(shí)也用255.255.248.0表示)。

在退化到極限的情況下,一個(gè)掩碼為32bit的子網(wǎng)就等價(jià)于一個(gè)IP地址。而零個(gè)合法bit的子網(wǎng)("0.0.0.0/0")等價(jià)于常量"_Default_",可以匹配任何IP地址。

IP地址

IP地址以點(diǎn)分十進(jìn)制形式表示了一個(gè)完整的因特網(wǎng)地址。一般來(lái)說(shuō),此地址代表一個(gè)主機(jī),但并不需要一個(gè)DNS域名與這個(gè)地址對(duì)應(yīng)。

示例

192.168.123.7

注意

一個(gè)IP地址不需要為一個(gè)DNS系統(tǒng)所解析,所以它能使apache獲取更高性能。

主機(jī)名

主機(jī)名是一個(gè)完整的DNS域名,可以通過(guò)DNS域名服務(wù)解析為一個(gè)或多個(gè)IP地址。它代表了一個(gè)邏輯主機(jī)(與相反)而且必須解析成至少一個(gè)IP地址(或經(jīng)常解析成具有不同IP地址的主機(jī)列表)。

例子

prep.ai.mit.edu
www.apache.org

注意

在很多情況下,指定一個(gè)IP地址代替主機(jī)名會(huì)更有效率。因?yàn)榭梢员苊庖淮蜠NS查詢(xún)。當(dāng)使用一個(gè)低速的PPP與域名服務(wù)器連接時(shí),Apache的域名解析會(huì)花費(fèi)相當(dāng)可觀的時(shí)間。

主機(jī)名不區(qū)分大小寫(xiě)并且始終認(rèn)為是錨定在DNS樹(shù)根上的,因此WWW.MyDomain.comwww.mydomain.com.(注意結(jié)尾點(diǎn)號(hào))是完全等同的。

參見(jiàn)

  • DNS相關(guān)問(wèn)題

<Proxy> 指令

說(shuō)明 應(yīng)用于所代理資源的容器
語(yǔ)法 <Proxy wildcard-url> ...</Proxy>
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

位于<Proxy>配置段中的指令僅作用于匹配的代理內(nèi)容。語(yǔ)句中可以使用shell風(fēng)格的通配符。

比如說(shuō):下例僅允許yournetwork.example.com中的主機(jī)通過(guò)您的代理服務(wù)器訪問(wèn)代理內(nèi)容:

<Proxy *>
Order Deny,Allow
Deny from all
Allow from yournetwork.example.com
</Proxy>

下例將在所有example.comfoo目錄下的文件通過(guò)代理服務(wù)器發(fā)送之前用INCLUDES過(guò)濾器進(jìn)行處理:

<Proxy http://example.com/foo/*>
SetOutputFilter INCLUDES
</Proxy>

ProxyBadHeader 指令

說(shuō)明 確定如何處理不合法的應(yīng)答頭
語(yǔ)法 ProxyBadHeader IsError|Ignore|StartBody
默認(rèn)值 ProxyBadHeader IsError
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy
兼容性 僅在 Apache 2.0.44 及以后的版本中可用

ProxyBadHeader指令決定mod_proxy如何處理不合法的應(yīng)答頭(比如丟失冒號(hào)(:))。參數(shù)的取值范圍如下:

IsError
以"502"(Bad Gateway)應(yīng)答中止請(qǐng)求。這是默認(rèn)行為。
Ignore
忽略,就像它們不存在一樣。
StartBody
在接收到第一個(gè)非法頭行時(shí)停止讀取頭,并將剩余部分當(dāng)作應(yīng)答體。這樣做有助于和一個(gè)不規(guī)范的、經(jīng)常忘記在應(yīng)答頭和應(yīng)答體之間插入空行的后端服務(wù)器協(xié)同工作。

ProxyBlock 指令

說(shuō)明 設(shè)置被代理屏蔽的語(yǔ)句、主機(jī)、域
語(yǔ)法 ProxyBlock *|word|host|domain [word|host|domain] ...
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

ProxyBlock指令指定了一個(gè)由空格分隔的語(yǔ)句、主機(jī)和/或域的列表。對(duì)所有匹配這些語(yǔ)句、主機(jī)和/或域的HTTP、HTTPS、FTP文檔的請(qǐng)求都將被代理服務(wù)器阻斷。代理模塊亦會(huì)在啟動(dòng)時(shí)嘗試確定列表中可能是主機(jī)名的項(xiàng)目對(duì)應(yīng)的IP地址,并將其緩沖用于匹配測(cè)試。比如說(shuō):

示例

ProxyBlock joes-garage.com some-host.co.uk rocky.wotsamattau.edu

通過(guò)IP地址,rocky.wotsamattau.edu將可能同樣被匹配。

請(qǐng)注意,wotsamattau已經(jīng)足夠匹配wotsamattau.edu了。

請(qǐng)注意

ProxyBlock *

將屏蔽對(duì)所有站點(diǎn)的連接。

ProxyDomain 指令

說(shuō)明 代理請(qǐng)求的默認(rèn)域名
語(yǔ)法 ProxyDomain Domain
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

此指令僅對(duì)位于局域網(wǎng)內(nèi)的Apache代理服務(wù)器有用。ProxyDomain指令指定了apache代理服務(wù)器歸屬的默認(rèn)域。如果遇到了一個(gè)對(duì)沒(méi)有域名的主機(jī)的請(qǐng)求,就會(huì)根據(jù)配置自動(dòng)生成一個(gè)加上了Domain的重定向應(yīng)答。

示例

ProxyRemote * http://firewall.mycompany.com:81
NoProxy .mycompany.com 192.168.112.0/21
ProxyDomain .mycompany.com

ProxyErrorOverride 指令

說(shuō)明 覆蓋代理內(nèi)容的錯(cuò)誤頁(yè)
語(yǔ)法 ProxyErrorOverride On|Off
默認(rèn)值 ProxyErrorOverride Off
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy
兼容性 僅在 Apache 2.0 及以后的版本中可用

此指令用于反向代理設(shè)置中您想為最終用戶(hù)提供觀感一致的錯(cuò)誤頁(yè)面時(shí)。它也同樣允許包含文件(通過(guò)mod_include的SSI)獲取錯(cuò)誤號(hào)并作出相應(yīng)的動(dòng)作。(默認(rèn)行為是顯示被代理的服務(wù)器的錯(cuò)誤頁(yè)面,將此項(xiàng)目設(shè)為"On"將顯示SSI錯(cuò)誤信息。)

ProxyIOBufferSize 指令

說(shuō)明 內(nèi)部緩沖區(qū)大小
語(yǔ)法 ProxyIOBufferSize bytes
默認(rèn)值 ProxyIOBufferSize 8192
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

ProxyIOBufferSize指令用于調(diào)整內(nèi)部緩沖區(qū)(作為輸入輸出數(shù)據(jù)的暫存器)的大小。取值必須小于等于8192 。

在絕大多數(shù)情況下,不需要調(diào)整這個(gè)設(shè)置。

<ProxyMatch> 指令

說(shuō)明 應(yīng)用于匹配正則表達(dá)式的代理資源的容器
語(yǔ)法 <ProxyMatch regex> ...</ProxyMatch>
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

<ProxyMatch><Proxy>指令基本相同,只是匹配字符串可以為正則表達(dá)式。

ProxyMaxForwards 指令

說(shuō)明 轉(zhuǎn)發(fā)請(qǐng)求的最大代理數(shù)目
語(yǔ)法 ProxyMaxForwards number
默認(rèn)值 ProxyMaxForwards 10
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy
兼容性 僅在 Apache 2.0 及以后的版本中可用

ProxyMaxForwards指令指定了允許轉(zhuǎn)發(fā)請(qǐng)求的最大代理數(shù)目。這個(gè)設(shè)置是為了避免無(wú)限代理循環(huán)或DoS攻擊的發(fā)生。

示例

ProxyMaxForwards 15

ProxyPass 指令

說(shuō)明 將一個(gè)遠(yuǎn)端服務(wù)器映射到本地服務(wù)器的URL空間中
語(yǔ)法 ProxyPass [path] !|url [key=value key=value ...]]
作用域 server config, virtual host, directory
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

該指令允許你將一個(gè)遠(yuǎn)端服務(wù)器映射到本地服務(wù)器的URL空間中,此時(shí)本地服務(wù)器并不充當(dāng)代理角色,而是充當(dāng)遠(yuǎn)程服務(wù)器的一個(gè)鏡像。path是一個(gè)本地虛擬路徑名,url是一個(gè)指向遠(yuǎn)程服務(wù)器的部分URL,并且不允許包含查詢(xún)字符串。

當(dāng)使用ProxyPass指令時(shí),ProxyRequests指令通常應(yīng)當(dāng)被設(shè)為 off

假設(shè)本地服務(wù)器地址是:http://example.com/ ,那么,

ProxyPass /mirror/foo/ http://backend.example.com/

將會(huì)導(dǎo)致對(duì)http://example.com/mirror/foo/bar的本地請(qǐng)求將會(huì)在內(nèi)部轉(zhuǎn)換為一個(gè)代理請(qǐng)求:http://backend.example.com/bar 。

"!"指令對(duì)于您不想對(duì)某個(gè)子目錄進(jìn)行反向代理時(shí)很有用。比如說(shuō):

ProxyPass /mirror/foo/i !
ProxyPass /mirror/foo http://backend.example.com

將會(huì)代理除/mirror/foo/i之外的所有對(duì)backend.example.com/mirror/foo的請(qǐng)求。

注意

順序很重要,您需要把拒絕指令放置在普通ProxyPass指令之前。

As of Apache 2.1, the ability to use pooled connections to a backend server is available. Using the key=value parameters it is possible to tune this connection pooling. The default for a Hard Maximum for the number of connections is the number of threads per process in the active MPM. In the Prefork MPM, this is always 1, while with the Worker MPM it is controlled by the ThreadsPerChild.

Setting min will determine how many connections will always be open to the backend server. Upto the Soft Maximum or smax number of connections will be created on demand. Any connections above smax are subject to a time to live or ttl. Apache will never create more than the Hard Maximum or max connections to the backend server.

ProxyPass /example http://backend.example.com smax=5 max=20 ttl=120 retry=300

Parameter Default Description
min 0 Minumum number of connections that will always be open to the backend server.
max 1...n Hard Maximum number of connections that will be allowed to the backend server. The default for a Hard Maximum for the number of connections is the number of threads per process in the active MPM. In the Prefork MPM, this is always 1, while with the Worker MPM it is controlled by the ThreadsPerChild. Apache will never create more than the Hard Maximum connections to the backend server.
smax max Upto the Soft Maximum number of connections will be created on demand. Any connections above smax are subject to a time to live or ttl.
ttl - Time To Live for the inactive connections above the smax connections in seconds. Apache will close all connections that has not been used inside that time period.
timeout Timeout Connection timeout in seconds. If not set the Apache will wait until the free connection is available. This directive is used for limiting the number of connections to the backend server together with max parameter.
acquire - If set this will be the maximum time to wait for a free connection in the connection pool. If there are no free connections in the pool the Apache will return SERVER_BUSY status to the client.
keepalive Off This parameter should be used when you have a firewall between your Apache and the backend server, who tend to drop inactive connections. This flag will tell the Operating System to send KEEP_ALIVE messages on inactive connections (interval depends on global OS settings, generally 120ms), and thus prevent the firewall to drop the connection. To enable keepalive set this property value to On.
retry 60 Connection pool worker retry timeout in seconds. If the connection pool worker to the backend server is in the error state, Apache will not forward any requests to that server until the timeout expires. This enables to shut down the backend server for maintenance, and bring it back online later.
loadfactor 1 Worker load factor. Used with BalancerMember. It is a number between 1 and 100 and defines the normalized weighted load applied to the worker.
route - Route of the worker when used inside load balancer. The route is a value appended to seesion id.
redirect - Redirection Route of the worker. This value is usually set dynamically to enable safe removal of the node from the cluster. If set all requests without session id will be redirected to the BalancerMember that has route parametar equal as this value.

If the Proxy directive scheme starts with the balancer:// then a virtual worker that does not really communicate with the backend server will be created. Instead it is responsible for the management of several "real" workers. In that case the special set of parameters can be add to this virtual worker.

Parameter Default Description
lbmethod - Balancer load-balance method. Select the load-balancing scheduler method to use. Either byrequests, to perform weighted request counting or bytraffic, to perform weighted traffic byte count balancing. Default is byrequests.
stickysession - Balancer sticky session name. The value is usually set to something like JSESSIONIDPHPSESSIONID, and it depends on the backend application server that support sessions.
nofailover Off If set to On the session will break if the worker is in error state or disabled. Set this value to On if backend servers do not support session replication.
timeout 0 Balancer timeout in seconds. If set this will be the maximum time to wait for a free worker. Default is not to wait.
maxattempts 1 Maximum number of failover attempts before giving up.

ProxyPass /special-area http://special.example.com/ smax=5 max=10
ProxyPass / balancer://mycluster stickysession=jsessionid nofailover=On
<Proxy balancer://mycluster>
BalancerMember http://1.2.3.4:8009
BalancerMember http://1.2.3.5:8009 smax=10
# Less powerful server, don't send as many requests there
BalancerMember http://1.2.3.6:8009 smax=1 loadfactor=20
</Proxy>

When used inside a <Location> section, the first argument is omitted and the local directory is obtained from the <Location>.

If you require a more flexible reverse-proxy configuration, see the RewriteRule directive with the [P] flag.

ProxyPassReverse 指令

說(shuō)明 調(diào)整由反向代理服務(wù)器發(fā)送的HTTP應(yīng)答頭中的URL
語(yǔ)法 ProxyPassReverse [path] url
作用域 server config, virtual host, directory
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

此指令使Apache調(diào)整HTTP重定向應(yīng)答中Location, Content-Location, URI頭里的URL。這樣可以避免在Apache作為反向代理使用時(shí),后端服務(wù)器的HTTP重定向造成的繞過(guò)反向代理的問(wèn)題。

只有明確指定的應(yīng)答頭會(huì)被重寫(xiě),其它應(yīng)答頭保持不變,并且HTML頁(yè)面中的URL也不會(huì)被修改。如果被代理的內(nèi)容包含絕對(duì)URL引用,那么將會(huì)繞過(guò)代理。有一個(gè)第三方模塊可以檢查并改寫(xiě)HTML中的URL引用,該模塊就是Nick Kew編寫(xiě)的mod_proxy_html。

path是本地虛擬路徑的名稱(chēng)。url是遠(yuǎn)端服務(wù)器的部分URL。與ProxyPass指令中的使用方法相同。

例如,假定本地服務(wù)器擁有地址http://example.com/ ,那么

ProxyPass /mirror/foo/ http://backend.example.com/
ProxyPassReverse /mirror/foo/ http://backend.example.com/
ProxyPassReverseCookieDomain backend.example.com public.example.com
ProxyPassReverseCookiePath / /mirror/foo/

不僅會(huì)把所有對(duì)http://example.com/mirror/foo/bar的請(qǐng)求直接轉(zhuǎn)換為對(duì)http://backend.example.com/bar的代理請(qǐng)求(由ProxyPass提供的功能),它還會(huì)重定向服務(wù)器backend.example.com的發(fā)送:當(dāng)http://backend.example.com/bar被它重定向到http://backend.example.com/quux時(shí),Apache會(huì)在轉(zhuǎn)交HTTP重定向應(yīng)答到客戶(hù)端之前調(diào)整它為http://example.com/mirror/foo/quux 。注意:被用于構(gòu)建URL的主機(jī)名與UseCanonicalName指令的設(shè)置有關(guān)。

注意,此ProxyPassReverse指令亦可與mod_rewrite的代理穿透特性(RewriteRule ... [P])聯(lián)用。因?yàn)樗灰蕾?lài)于相應(yīng)的ProxyPass指令。

當(dāng)在<Location>配置段中使用時(shí),第一個(gè)參數(shù)會(huì)被忽略而采用由<Location>指令指定的本地目錄。

ProxyPassReverseCookieDomain 指令

說(shuō)明 Adjusts the Domain string in Set-Cookie headers from a reverse- proxied server
語(yǔ)法 ProxyPassReverseCookieDomain internal-domain public-domain
作用域 server config, virtual host, directory
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

Usage is basically similar to ProxyPassReverse, but instead of rewriting headers that are a URL, this rewrites the domain string in Set-Cookie headers.

ProxyPassReverseCookiePath 指令

說(shuō)明 Adjusts the Path string in Set-Cookie headers from a reverse- proxied server
語(yǔ)法 ProxyPassReverseCookiePath internal-path public-path
作用域 server config, virtual host, directory
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

Usage is basically similar to ProxyPassReverse, but instead of rewriting headers that are a URL, this rewrites the path string in Set-Cookie headers.

ProxyPreserveHost 指令

說(shuō)明 使用進(jìn)入的HTTP請(qǐng)求頭來(lái)發(fā)送代理請(qǐng)求
語(yǔ)法 ProxyPreserveHost On|Off
默認(rèn)值 ProxyPreserveHost Off
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy
兼容性 僅在 Apache 2.0.31 及以后的版本中可用

當(dāng)啟用時(shí),此選項(xiàng)將把傳入請(qǐng)求的"Host:"行傳遞給被代理的主機(jī),而不是傳遞在ProxyPass中指定的主機(jī)名。

此選項(xiàng)一般為Off狀態(tài)。It is mostly useful in special configurations like proxied mass name-based virtual hosting, where the original Host header needs to be evaluated by the backend server.

ProxyReceiveBufferSize 指令

說(shuō)明 代理HTTP和FTP連接的接收緩沖區(qū)大小(字節(jié))
語(yǔ)法 ProxyReceiveBufferSize bytes
默認(rèn)值 ProxyReceiveBufferSize 0
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

ProxyReceiveBufferSize指令為增加的吞吐量指定了代理HTTP和FTP連接的(TCP/IP)網(wǎng)絡(luò)接收緩沖區(qū)。這個(gè)值必須大于512 ,或設(shè)置為"0"表示使用系統(tǒng)默認(rèn)的緩沖大小。

示例

ProxyReceiveBufferSize 2048

ProxyRemote 指令

說(shuō)明 用于處理某些特定請(qǐng)求的遠(yuǎn)端代理
語(yǔ)法 ProxyRemote match remote-server
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

此指令定義了此代理的遠(yuǎn)端代理。match可以是遠(yuǎn)端服務(wù)器支持的URL形式的名稱(chēng)、或是遠(yuǎn)端服務(wù)器使用的部分URL、或是代表服務(wù)器可以接受所有請(qǐng)求的"*"。remote-server是遠(yuǎn)端服務(wù)器的部分URL。語(yǔ)法為:

remote-server = scheme://hostname[:port]

scheme是與遠(yuǎn)端服務(wù)器交換信息時(shí)使用的協(xié)議;本模塊暫時(shí)只支持http協(xié)議。

示例

ProxyRemote http://goodguys.com/ http://mirrorguys.com:8000
ProxyRemote * http://cleversite.com
ProxyRemote ftp http://ftpproxy.mydomain.com:8080

在最后一個(gè)例子中,代理會(huì)將封裝到另外一個(gè)HTTP代理請(qǐng)求中的FTP請(qǐng)求轉(zhuǎn)交到另外一個(gè)能處理它們的代理去。

此選項(xiàng)也支持反向代理配置:一個(gè)后端web服務(wù)器可以被嵌入到一個(gè)虛擬主機(jī)的URL空間中,哪怕它是由另一個(gè)代理轉(zhuǎn)交過(guò)來(lái)的。

ProxyRemoteMatch 指令

說(shuō)明 處理匹配正則表達(dá)式的請(qǐng)求的遠(yuǎn)端代理
語(yǔ)法 ProxyRemoteMatch regex remote-server
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

ProxyRemoteMatchProxyRemote令基本相同。除了第一個(gè)參數(shù)是由一個(gè)請(qǐng)求的URL變成了匹配的正則表達(dá)式。

ProxyRequests 指令

說(shuō)明 啟用正向(標(biāo)準(zhǔn))代理請(qǐng)求
語(yǔ)法 ProxyRequests On|Off
默認(rèn)值 ProxyRequests Off
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

此指令將允許或禁止Apache作為正向代理服務(wù)器的功能(設(shè)置為Off并不會(huì)禁用ProxyPass指令)。

在一個(gè)典型的反向代理配置中,此可選項(xiàng)一般設(shè)置為Off。

為了能夠代理HTTP或FTP站點(diǎn),mod_proxy_httpmod_proxy_ftp必須同時(shí)存在于服務(wù)器中。

警告

在您沒(méi)有對(duì)服務(wù)器采取安全措施之前,請(qǐng)不要用ProxyRequests啟用您的代理。一個(gè)開(kāi)放的代理服務(wù)器不僅對(duì)您的網(wǎng)絡(luò)有威脅,對(duì)整個(gè)因特網(wǎng)來(lái)說(shuō)也同樣如此。

ProxyTimeout 指令

說(shuō)明 代理請(qǐng)求的網(wǎng)絡(luò)超時(shí)
語(yǔ)法 ProxyTimeout seconds
默認(rèn)值 ProxyTimeout 300
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy
兼容性 僅在 Apache 2.0.31 及以后的版本中可用

此指令允許用戶(hù)對(duì)代理請(qǐng)求指定一個(gè)超時(shí)值。當(dāng)你有一個(gè)很慢/錯(cuò)誤多多的應(yīng)用服務(wù)器經(jīng)常掛起,而您寧愿返回一個(gè)超時(shí)的失敗信息也不愿意繼續(xù)等待不知道多久的時(shí)候,這個(gè)功能是很有用的。

ProxyVia 指令

說(shuō)明 控制代理對(duì)Via應(yīng)答頭的使用
語(yǔ)法 ProxyVia On|Off|Full|Block
默認(rèn)值 ProxyVia Off
作用域 server config, virtual host
狀態(tài) 擴(kuò)展(E)
模塊 mod_proxy

此指令控制代理對(duì)"Via:"頭的使用。它的目的是控制位于代理服務(wù)器鏈中的代理請(qǐng)求的流向。參閱RFC 2616(HTTP/1.1)14.45小節(jié)以獲得關(guān)于"Via:"頭的解釋。

  • 如果設(shè)置為默認(rèn)值Off ,將不會(huì)采取特殊的處理。如果一個(gè)請(qǐng)求或應(yīng)答包含"Via:"頭,將不進(jìn)行任何修改而直接通過(guò)。
  • 如果設(shè)置為On每個(gè)請(qǐng)求和應(yīng)答都會(huì)對(duì)應(yīng)當(dāng)前主機(jī)得到一個(gè)"Via:"頭。
  • 如果設(shè)置為Full ,每個(gè)產(chǎn)生的"Via:"頭中都會(huì)額外加入Apache服務(wù)器的版本,以"Via:"注釋域出現(xiàn)。
  • 如果設(shè)置為Block ,每個(gè)代理請(qǐng)求中的所有"Via:"頭行都將被刪除。且不會(huì)產(chǎn)生新的"Via:"頭。
Previous article: Next article: