Varnish http缓存服务器

http://blog.51cto.com/hexiaoshuai/1909183

https://jefferywang.gitbooks.io/varnish_4_1_doc_zh/content/

# This is an example VCL file for Varnish.
#
# It does not do anything by default, delegating control to the
# builtin VCL. The builtin VCL is called when there is no explicit
# return statement.
#
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples.

# Marker to tell the VCL compiler that this VCL has been adapted to the
# new 4.0 format.
vcl 4.0;

# Default backend definition. Set this to point to your content server.
backend phpmyadmin {
    .host = "48.57.222.83";
    .port = "8888";
    .probe = {
        .url = "/";
        .timeout = 1s;
        .interval = 5s;
        .window = 5;
        .threshold = 3;
    }
}
backend korea {
    .host = "121.65.111.199";
    .port = "8888";
}


sub vcl_recv {
    # Happens before we check if we have this in cache already.
    #
    # Typically you clean up the request here, removing cookies you don't need,
    # rewriting the request, etc.
    # unset req.http.cookie;

    if (req.http.host ~ "korea.sadprincess.com") {
        set req.backend_hint = korea;
    } elsif (req.http.host ~ "phpmyadmin.sadprincess.com") {
        set req.backend_hint = phpmyadmin;
    }

}

sub vcl_backend_response {
    # Happens after we have read the response headers from the backend.
    #
    # Here you clean the response headers, removing silly Set-Cookie headers
    # and other mistakes your backend does.
}

sub vcl_deliver {
    # Happens when we have all the pieces we need, and are about to send the
    # response to the client.
    #
    # You can do accounting or modifying the final object here.
}
原文地址:https://www.cnblogs.com/boundless-sky/p/10207508.html