2015-05-01 82 views
0

我試着用清漆緩存2網站:光油緩存只有特定的URL路徑

  1. http://services.gradle.org
  2. http://nodejs.org/dist/

我已經配置了2個DNS條目:的NodeJS代理和gradle-代理

在我的瀏覽器中,如果我訪問http://gradle-proxy,我將重定向到清漆緩存網站services.gradle.org。所以這部分工作。

但是,如何配置它,以便當我去http://nodejs-proxy時,我的清漆機器只緩存並顯示http://nodejs.org/dist/

我default.vcl配置爲:

backend gradle { 
    .host = "207.223.250.8"; 
    .port = "80"; 
    .connect_timeout = 6000s; 
    .first_byte_timeout = 6000s; 
    .between_bytes_timeout = 6000s; 
} 

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. 

    if (req.http.host == "gradle-proxy.corp.appdynamics.com") { 
     set req.backend_hint = gradle; 
    } 

    if (! req.url ~ "^/dist/") { 
     return(pass); 
    } 
    return(lookup); 

} 

謝謝

回答

0

啊,我得到了這個工作由RM:

if (! req.url ~ "^/dist/") { 
    return(pass); 
} 
return(lookup); 

,並補充說:

sub vcl_recv { 
    if (req.http.host == "nodejs-proxy") { 
      set req.http.host = "nodejs.org"; 
      set req.url = regsub(req.url, "^", "/dist"); 
    } 
} 

backend nodejs { 
    .host = "165.225.133.150"; 
    .port = "80"; 
    .connect_timeout = 6000s; 
    .first_byte_timeout = 6000s; 
    .between_bytes_timeout = 6000s; 
}