使用socket.io将varnish重定向运行到节点js服务器

时间:2015-06-28 07:54:48

标签: node.js apache socket.io varnish

所以我正在运营一个网站,在前面它是一个简单的Apache主页并不重要。但我想在子域上运行sync client



backend apache {
    .host = "127.0.0.1";
    .port = "8051";
    .connect_timeout = 1s;
}

backend node {
    .host = "127.0.0.1";
    .port = "8081";
    .connect_timeout = 1s;
}



backend bot {
    .host = "127.0.0.1";
    .port = "8080";
    .connect_timeout = 1s;
}





sub vcl_recv {
    if(req.http.host == "Base-domain.com") {
        set req.backend = apache;
    }
    if(req.http.host == "bot.base-domain.com") {
        set req.backend = bot;
    }
	
	    if(req.http.host == "sync.base-domain.com") {
        set req.backend = node;
    }
	
  if (req.http.Upgrade ~ "(?i)websocket") {
    set req.backend = node;
    return (pipe);
  }

  if (req.http.host == "sync.based-domain.moe") {  
    if (req.url ~ "^/socket.io/") {
        set req.backend = node;
        return (pipe);  
    }
    return (pass);  
  }

}

sub vcl_pipe {
  if (req.http.upgrade) {
    set bereq.http.upgrade = req.http.upgrade;
  }
}




搜索所有有关如何运行节点JS的信息,因为有一个套接字的节点JS没有帮助。由于连接问题,websocket在1338而不是1337.相当新的,所以不知道该怎么做。

我应该更改清漆还是进一步修改节点的配置?提前谢谢。

0 个答案:

没有答案