【发布时间】:2014-06-28 21:42:58
【问题描述】:
更新:已解决!检查我对这个问题的回答。
我有一个 nginx 服务器作为前端,它使用 varnish 作为他的后端,而 varnish 使用 apache2 作为他的后端。类似:
nginx:
Nginx 被配置为监听 *:80
location / {
proxy_pass http://127.0.0.1:81;
}
清漆:
Varnish 配置为监听 127:0.0.1:81
backend 1 {
.host = "127.0.0.1";
.port = "8081";
...
}
backend 2 {
.host = "127.0.0.1";
.port = "8080";
...
}
sub vcl_recv {
if (req.http.host == <1 domain>) {
# setting the backend to 1
set req.backend = 1;
} else {
# setting the backend to 2
set req.backend = 2;
}
...
}
apache2:
apache 配置为监听 127.0.0.1:8080 和 127.0.0.1:8081
// ports.conf
VirtualHost 127.0.0.1:8080
Listen 8080
VirtualHost 127.0.0.1:8081
Listen 8081
// other vhost confs
<VirtualHost 127.0.0.1:8080>
...
</VirtualHost>
<VirtualHost 127.0.0.1:8081>
...
</VirtualHost>
如何将 HTTP 主机(如 example.com 或 secure.example.com)从 nginx 传递到 varnish,以识别请求的站点?
【问题讨论】: