我怎样才能使Apache和Nginx都在Varnish之后?

我有一个设置,我有端口8080上的Apache背后的端口80上的Varnish监听,而我打算在8081上使用Nginx。我的vps的控制面板只支持Apache,但是我想testing一个我在VPS上托pipe的网站上的Nginx ,因为Varnish已经在80了,所以我不能在同一个端口上有Nginx。

我不想完全摆脱Apache,因为我仍然需要它来访问我的vps的控制面板, Sentora准确地说,Apache位于8080上。在这里问的问题,OP想要有两个不同的域不同IP只是在Apache上,所以它并没有真正的帮助。

另外,我读了一些关于在我的vcl中使用server.port指令的地方,但我不知道如何去做。 以下是我的default.vcl的一部分:

 backend default { .host = "127.0.0.1"; .port = "8080"; } 

PS:我还没有安装Nginx。

在这里,您想要在Varnish中设置一个额外的后端,并将一些请求发送给它。

首先为Nginx添加一个新的后端:

 backend nginx { .host = "127.0.0.1"; .port = "8081"; } 

然后你可以路由一些请求。 这通常在vcl_recv子例程中完成。 例如,如果通过域名sentora.example.org访问sentora.example.org

 sub vcl_recv { if (req.http.host ~ "(?i)^sentora.example.org$") { # Route requests to sentora.example.org to the old Apache backend. set req.backend = default; } else { # Everything else to nginx. set req.backend = nginx; } } 

有关更多示例,请参阅高级后端configuration 。 “ 清漆configuration语言”文档中还有很多示例。