關於apache模塊mod_proxy中ProxyPass和ProxyPassReverse |
關於apache模塊mod_proxy中ProxyPass和ProxyPassReverse指令的使用問題 關於apache模塊mod_proxy中的ProxyPass和ProxyPassReverse的使用問題 對應詳細使用說明如下: 關於apache模塊mod_proxy中的ProxyPass和ProxyPassReverse的使用問題 對應詳細使用說明如下: ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ (一).ProxyPass 指令 說明: 將一個遠端服務器映射到本地服務器的URL空間中 語法: ProxyPass [路徑] !|url 上下文: 服務器配置, 虛擬主機 狀態: Extension 模塊: mod_proxy 指令對於您不想對某個子目錄進行反向代理時很有用。比如說: ProxyPass /mirror/foo/i ! ProxyPass /mirror/foo http://foo.com 將會代理除對/mirror/foo/i請求之外的所有對 foo.com 的/mirror/foo請求。 注意:順序很重要,您需要把特例情況放在一般代理通過指令 當在配置段中使用時,第一個參數會被忽略而是採用由指令指定的本地目錄。 如果您需要一個更加靈活的反向代理配置,請參見使用[P]標記的RewriteRule指令。 ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ (二).ProxyPassReverse 指令 說明: 調整由反向代理服務器發送的HTTP迴應頭中的URL 語法: ProxyPassReverse [路徑] url 上下文: 服務器配置, 虛擬主機 狀態: Extension 模塊: mod_proxy 此指令使 Apache 調整HTTP重定向迴應中Location, Content-Location和URI頭裏的URL。 HTTP redirect responses. This is essential when Apache is used as a reverse proxy to avoid by-passing the reverse proxy because of HTTP redirects on the backend servers which stay behind the reverse proxy. 路徑是本地虛擬路徑的名稱。 url遠端服務器的部分URL。與ProxyPass指令中的使用方法相同。 示例: 假定本地服務器擁有地址 http://wibble.org/ ;那麼 ProxyPass /mirror/foo/ http://foo.com/ ProxyPassReverse /mirror/foo/ http://foo.com/ will not only cause a local request for the to be internally converted into a proxy request to (the functionality ProxyPass provides here). It also takes care of redirects the server foo.com sends: when http://foo.com/bar is redirected by him to http://foo.com/quux Apache adjusts this to http://wibble.org/mirror/foo/quux before forwarding the HTTP redirect response to the client. Note that the hostname used for constructing the URL is chosen in respect to the setting of the UseCanonicalName directive. Note that this ProxyPassReverse directive can also be used in conjunction with the proxy pass-through feature ("RewriteRule ... [P]") from mod_rewrite because its doesn't depend on a corresponding ProxyPass directive. When used inside a section, the first argument is ommitted and the local directory is obtained from the . ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ (三).實際問題解決及說明: ProxyPass /mysys/ http://192.168.8.11:81/mysys/ ProxyPassReverse /mysys/ http://192.168.8.11:81/mysys/ ① 這裏有兩個mysys,我們分別叫做叫做path_wapm和path_iis ProxyPass /path_wapm/ http://192.168.8.11:81/path_iis/ path_wapm:這個是虛擬的目錄名稱,可以任意指定一個 ②ProxyPassReverse /path_wapm/ http://192.168.8.11:81/path_iis/ path_iis:這個必須通過81端口可以訪問的 那麼,訪問 http://wapm 服務器/path_wapm的時候,實際訪問的將自動轉換爲了 http://192.168.8.11:81/path_iis/ 的. ③path_wapm如果不加,就不知道訪問哪一個虛擬目錄的時候需要使用ASP, path_iis不加,那麼就是訪問 http://192.168.8.11:81/ 的效果了 簡單來說:就是把IIS站點的一個目錄,當作WAPM的一個虛擬目錄來訪問, 可以是IIS站點的一個子目錄,也可以是根目錄. ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ (四).如果還有不明白的地方,請到 [url=http://w.yi.org/ftp/FAPM/apache/Apache2/zh/mod/mod_proxy.html#查對! 文章來源:http://blog.chinaunix.net/u/4775/showart_14378.html |