varnish, apache and namebased virtual host with own ip addresses

放肆的年华 提交于 2019-12-11 05:13:01

问题


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.

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.

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


回答1:


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

Example :

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)



来源:https://stackoverflow.com/questions/8111317/varnish-apache-and-namebased-virtual-host-with-own-ip-addresses

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!