本文介绍了清漆,Apache和namebased虚拟主机与自己的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Apache2的-Web服务器与几个基于域名的虚拟主机;每台主机都有自己的IP地址,因此Apache不侦听*:80,但123.456.789.012:80

I have a apache2-webserver with several name-based virtual hosts; each host has its own ip address, so the apache is not listening on *:80, but on 123.456.789.012:80.

现在我要缓存清漆的网站。我发现了几个HOWTO文档,无论是基于IP的主机(监听*:80)。或者只有一个IP地址的主机namebased

Now I want to cache the websites with varnish. I found several howtos, either ip-based hosts (listening on *:80) or namebased hosts with only one ip address.

我怎么都设置我的清漆,使之与我的Apache2配置工作?

How do I have to setup my varnish to make it work with my apache2-configuration?

推荐答案

您将需要每个IP一个后端,然后发送的每个主机到正确的后端。

You will need one backend per IP, and then send each hostname to the right backend.

例如:

backend Site1 {
    .host = "123.456.789.001";
    .port = "80";
}

backend Site2 {
    .host = "123.456.789.002";
    .port = "80";
}

sub vcl_recv {
    if (req.http.Host == "www.site1.com") {
        set req.backend Site1
    } elseif (req.http.Host == "www.site2.com") {
        set req.backend Site2
    } elseif
}

(不知道后端语法,因为我只用导演)

(Not sure about backend syntax since I only use directors)

这篇关于清漆,Apache和namebased虚拟主机与自己的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 18:04