2013-10-29 48 views
0

這個問題has been asked before,並在簡歷我要配置這樣的場景:子域的碼頭應用與Apache的mod_proxy沒有上下文的名稱

1 - 我有很多應用一個碼頭7服務器,例如:APP1,APP2 ,app3等

2 - 我有一個主域和每個Jetty應用程序的一個子域,例如: app1.example.com,app2.example.com,app3.example.com等

3 - 我嘗試使用Apache 2.2.22 mod_proxy在Apache管理的域之間屏蔽這些Jetty應用程序。這是我的一個應用程序的功能配置:

<VirtualHost *:80> 
     ServerName example.com 
     ServerAlias app1.example.com 
     ProxyRequests Off 
     ProxyPreserveHost On 

     <Proxy *:80> 
      Order deny,allow 
      Allow from all 
     </Proxy> 
     ProxyPass /app1 http://localhost:8080/app1 
</VirtualHost> 

這種配置工作,但是,它不會刪除上下文名稱,URI是:

http://app1.example.com/app1/?args=or/pages/etc ...

有辦法刪除這個上下文名稱,留下一個完整的透明URIs? e.g:

http://app1.example.com/?args=or/pages/etc ..

在網絡上的所有實施例使用上URIS此上下文名稱:/

其他信息:

  • VM與Ubuntu 12.04;
  • 碼頭7沒有修改;
  • 啓用了mod_proxy和mod_rewrite的Apache 2.2.22(默認啓用了一些基本的mods);
  • 數字海洋虛擬機管理器中的正確和有效的CNAME和域名;

在此先感謝。

回答

0

我已經找到了解決辦法:

1 - 安裝的Apache2國防部代理-HTML這個特定的lib:

sudo apt-get install libapache2-lib-proxy-html 

2 - 啓用該新模塊:

sudo a2enmod proxy_html 

3 - 配置您的應用程序描述符:

sudo vim /etc/apache2/sites-enabled/app1 

與此內容:

<VirtualHost *:80> 
     ServerAdmin [email protected] 
     ServerName app1.example.com 
     ProxyRequests Off 
     ProxyPreserveHost On 

     <Proxy *:80> 
      Order deny,allow 
      Allow from all 
     </Proxy> 
     ProxyPass/http://localhost:8080/app1 
     ProxyPassReverse/http://localhost:8080/app1 

     ProxyHTMLURLMap//app1/ 

     <Location /> 
       Order allow,deny 
       Allow from all 
     </Location> 
</VirtualHost> 

4 - 重新啓動的Apache2服務:

sudo service apache2 restart 

跨快樂,透明的要求:

http://app1.example.com/some/beautiful/page