2016-03-02 72 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>