基于路径的虚拟主机,包括乘客、机架和Apache

基于路径的虚拟主机,包括乘客、机架和Apache,apache,mod-rewrite,routing,rack,Apache,Mod Rewrite,Routing,Rack,我正在尝试为我们的API创建一个基于路径的版本控制系统,类似于: GET api.ingeniapi.com/v1/items <VirtualHost *:443> ServerName api.ingeniapi.com:443 RackEnv production DocumentRoot /services/api_gateway/current/public <Directory /services/api_gateway/current/pub

我正在尝试为我们的API创建一个基于路径的版本控制系统,类似于:

GET api.ingeniapi.com/v1/items
<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>
vs

如何设置Apache以将流量从这两条路径路由到不同的机架应用程序

现在我有一些类似于:

GET api.ingeniapi.com/v1/items
<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>

ServerName api.ingeniapi.com:443
RackNV生产
DocumentRoot/services/api_gateway/current/public
通融
选项-多视图
ServerName api.test.ingeniapi.com
RackNV生产
DocumentRoot/services/api_gateway/current/public
通融
选项-多视图
如下所述:

您可以使用
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>

ServerName api.ingeniapi.com
RackNV生产
DocumentRoot/nowa_应用程序/服务/api_网关/当前/公共
通融
选项-多视图
#增加了以下内容:
别名/v2/nowa\u应用程序/服务/api\u网关\u v2/current/public
乘客座/v2
PassengerAppRoot/nowa\u应用程序/服务/api\u网关\u v2/当前
通融
选项-多视图