- 论坛徽章:
- 0
|
高手们好 我们现在是这样的架构 前端是nginx进行反向代理 静态文件发给后面的varnish组 动态文件aspx发给后端的iis处理 现在的问题是 varnish配置文件中如何接收发来的请求呢 我的配置如下:
nginx:
upstream varnishtest{
192.168.0.2:80 weight=2
192.168.0.3:80 weight=2
192.168.0.4:80 weight=2
}
server {
listen 58.xx.xx.xx:80;
server_name test.vcoole.com;
access_log /home/log/test.log main;
location / {
proxy_pass http://vcloole.com;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~* .*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$ {
proxy_pass http://varnishtest ;
}
location ~* .*\.aspx$ {
proxy_pass 172.18.83.20 ;
}
}
varnish:
backend myblogserver {
set backend.host = "192.168.0.20";
set backend.port = "80";
}
acl purge {
"localhost";
"127.0.0.1";
"192.168.1.0"/24;
}
sub vcl_recv {
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
lookup;
}
if (req.http.host ~ "^image[1-5].xx.com.cn") {
set req.backend = myblogserver;
if (req.request != "GET" && req.request != "HEAD") {
pipe;
}
else {
lookup;
}
}
else {
error 404 "press Cache Server";
lookup;
}
}
sub vcl_hit {
if (req.request == "PURGE") {
set obj.ttl = 0s;
error 200 "Purged.";
}
}
sub vcl_miss {
if (req.request == "PURGE") {
error 404 "Not in cache.";
}
}
sub vcl_fetch {
if (req.request == "GET" && req.url ~ "\.(jpg|gif|xml|ico|bmp)$") {
set obj.ttl = 7200s;
}
else {
set obj.ttl = 30d;
}
}
这个是我以前用的 访问的 image[1-5].xx.com.cn,则转到后端真是存储192.168.0.20 现在前端过来的是ip地址吧 这个地方改怎么写呢 高手指点 |
|