2016-03-02 117 views
1

所以,我有兩臺服務器,讓我們稱之爲好的#服務器和#其他#服務器阿帕奇:重寫然後代理

不錯#服務器是什麼樣的客戶會跟和運行Apache2的簡單執行基本的反向代理服務,#另一臺#服務器託管端口上的專有應用程序服務器。我需要在通過之前完全重寫兩個網址,但只需向其他所有網址添加一個文件夾即可。

下面一些例子:

User Requests: nice#server/ 
Apache requests a#another#server:8080/appname 

User Requests: nice#server/css#css 
Apache requests a#another#server:8080/appname/css#css 

User Requests: nice#server/a 
Apache requests a#another#server:8080/appname/command1?name=option1 

User Requests: nice#server/b 
Apache requests a#another#server:8080/appname/app2?name=option2 

我已經做了很多的谷歌搜索和測試上這一點,但似乎無法得到它的工作,對不起,我沒有遵守我試過的鏈接! !現在我已經將vHost文件剝離了。

<VirtualHost *:80> 
    ServerName    service#domain#com 
    ErrorLog    ${APACHE_LOG_DIR}/service-domain-com-error.log 
    LogLevel    warn 
    CustomLog    ${APACHE_LOG_DIR}/service-domain-com-access.log combined 
    ProxyPreserveHost  On 
    ProxyRequests   off 
    ProxyPass    /a#another#server:8080/ 
    ProxyPassReverse  /a#another#server:8080/ 
</VirtualHost> 

在此先感謝有關如何執行此操作的任何指導。

回答

1

我試圖通過一些試驗和錯誤來解決這個問題。在這裏發佈解決方案以防其他人遇到問題。

工作配置文件

<VirtualHost *:80> 
    ServerName    service.domain.com 

    ErrorLog    ${APACHE_LOG_DIR}/internal-fqdn-error.log 
    LogLevel    warn 
    CustomLog    ${APACHE_LOG_DIR}/internal-fqdn-access.log combined 

    RewriteEngine   On 
    RewriteRule    ^/a$ /appname/command1?name=option1 [PT] 

    ProxyPreserveHost  On 
    ProxyRequests   off 
    ProxyPass    /  http://a.another.server:8080/ 
    ProxyPassReverse  /  http://a.another.server:8080/ 
</VirtualHost>