在Apache2后面运行Thin

目前我的Ubuntu服务器使用Apache2 + Passenger运行RubyOnRails应用程序。

现在我需要部署一个Sinatra(普通的Ruby应用程序),它需要在Thin而不是Passenger上运行。

我熟悉configurationApache,并希望继续以这种方式,VirtualHosts(在网站可用)等。

如何将Apache中的VirtualHost“路由”到瘦服务器?

您将Apacheconfiguration为“反向代理” – 该search术语将向您提供有关configuration的大量信息,但是这里有一个示例,可以帮助您find所需部署的大部分方法。

如果你将使用不同的主机名和不同的<VirtualHost> ,那么你可以做这样的事情:

 <VirtualHost *:80> ServerName sinatra.example.com # Any normal settings you use go here; access logs, ServerAdmin, etc # Replace the 9999 below with the port that thin is using, note that it can't # be the same as Apache's port. # This can also be a service running on adifferent computer if you # use another IP address instead of 127.0.0.1 ProxyPass / http://127.0.0.1:9999/ ProxyPassReverse / http://127.0.0.1:9999/ </VirtualHost> 

另一种可能对你有用的configuration是将其作为现有的<VirualHost>一个子目录; 你会添加一个<Location>块到你现有的configuration:

 <Location /sinatra/> ProxyPass http://127.0.0.1:9999/ ProxyPassReverse http://127.0.0.1:9999/ </Location> 

您可以使用Varnish来路由应用程序请求。 我在RoR / Varnish / NGINX堆栈上完成了上一份工作。

此外,清漆caching是真棒!