我正在尝试为我们的API创建基于路径的版本控制系统,例如:
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>
答案 0 :(得分:1)
如此处所述:http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rack_to_sub_uri
您可以使用PassengerBaseURI
和Alias
<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>