2011-02-25 7 views
5

Etki alanından sonra gelenlere bağlı olarak farklı uygulamalara yönlendiren bir sanal konak, dev.company.com oluşturmaya çalışıyorum. Özellikle, benim istediğim:Adlandırılmış bir VirtualHost İçinde birden çok ServerPath yönergesi kullanma

  • /Jenkins'i - rotaya bir Jenkins sunucuya
  • /uygulamalar - rotaya bir açılış sayfasına çeşitli uygulamalar için bağlantıları
  • /yonca ile - rotaya belirli Jenkins inşa raporu - http://dev.company.com/jenkins/job/proj-master-clover/clover/
  • /- her şey olması gerektiği aşağıdaki yapılandırma kullanıyorum

Tomcat sunucusuna yönlendirmek:

<VirtualHost *:80> 
    ServerName dev.company.com 

    ServerPath /jenkins 
    ProxyPass /jenkins http://easyrider:8080/jenkins 
    ProxyPassReverse /jenkins http://easyrider:8080/jenkins 

    ServerPath /clover 
    Redirect /clover http://dev.company.com/jenkins/job/proj-master-clover/clover/ 

    ServerPath /apps 
    DocumentRoot "/usr/local/sites/developers" 
    <Directory "/usr/local/sites/developers"> 
     DirectoryIndex index.html 
     Options Indexes MultiViews 
    </Directory> 

    ServerPath/
    ProxyPass/http://tomcat_server:8080/ 
    ProxyPassReverse/http://tomcat_server:8080/ 
</VirtualHost> 

http://dev.company.com/jenkins iyi çalışıyor, ancak/apps ve/clover her zaman Tomcat sunucusuna yeniden yönlendiriyor. Bunu yapmanın doğru yolu nedir?

cevap

8

ServerPath'ın kullanımı çoğunlukla eski tarayıcılar içindir. hüner, ancak, bir Alias ​​alma ve tümünü yakalama kullanıyorsanız nerede Yönlendirme bir VirtualHost çalışmaya: ProxyPass /path ! notasyonu

Yani benim son:

ProxyPass/<url> 

belli yolları görmezden ProxyPass söylemek

<VirtualHost> 
    ServerName dev.company.com 

    ProxyPass /jenkins http://easyrider:8080/jenkins 
    ProxyPassReverse /jenkins http://easyrider:8080/jenkins 

    # Tells ProxyPass to ignore these paths as they'll be handled by Alias and Redirect 
    ProxyPass /clover ! 
    ProxyPass /apps !   

    Redirect /clover http://dev.company.com/jenkins/job/proj-master-clover/clover/ 

    Alias /apps "/usr/local/sites/developers" 
    <Directory "/usr/local/sites/developers"> 
     DirectoryIndex index.html 
     Options Indexes MultiViews 
    </Directory> 


    ProxyPass/http://tomcat_server:8080/ 
    ProxyPassReverse/http://tomcat_server:8080/ 
</VirtualHost> 

ve URL'ler şunlardır: Sanal Ana şuna benzer

http://dev.company.com/jenkins* - will proxy to jenkins http://dev.company.com/jenkins 
http://dev.company.com/apps - will proxy to http://dev.company.com/apps/ 
http://dev.company.com/clover - will redirect to http://dev.company.com/jenkins/job/proj-master-clover/clover/ 
and everything else will go to tomcat at tomcat_server:8080