2014-02-05 58 views
0
基於路徑VirtualHosts

我想爲我們的API基於路徑的版本系統,是這樣的:與客運,機架和Apache

GET api.ingeniapi.com/v1/items 

VS

GET api.ingeniapi.com/v2/items/magic_new_thing 

如何設置Apache從這些路由流量兩條路徑不同的機架應用

現在,我有這樣的事情:

<VirtualHost *:443> 
    ServerName api.ingeniapi.com:443 
    RackEnv production 

    DocumentRoot /services/api_gateway/current/public 

    <Directory /services/api_gateway/current/public > 
    Allow from all 
    Options -MultiViews 
    </Directory> 

</VirtualHost> 


<VirtualHost *:80> 
    ServerName api.test.ingeniapi.com 
    RackEnv production 

    DocumentRoot /services/api_gateway/current/public 

    <Directory /services/api_gateway/current/public > 
    Allow from all 
    Options -MultiViews 
    </Directory> 
</VirtualHost> 

回答

1

由於這裏概述:http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rack_to_sub_uri

你可以做一些事情,這樣,使用PassengerBaseURIAlias

<VirtualHost *:80> 
    ServerName api.ingeniapi.com 
    RackEnv production 

    DocumentRoot /nowa_app/services/api_gateway/current/public 
    <Directory /nowa_app/services/api_gateway/current/public > 
    Allow from all 
    Options -MultiViews 
    </Directory> 

    # These have been added: 
    Alias /v2 /nowa_app/services/api_gateway_v2/current/public 
    <Location /v2> 
     PassengerBaseURI /v2 
     PassengerAppRoot /nowa_app/services/api_gateway_v2/current 
    </Location> 
    <Directory /nowa_app/services/api_gateway_v2/current/public> 
     Allow from all 
     Options -MultiViews 
    </Directory> 
</VirtualHost>