0

I have several web camera and want it to go the traffic through the Varnish.

Each webcam has its own web server. I want to reach first, when I page cam.city.travel:4444/cam1/ that then show the camera 1 and at the page cam.city.travel:4444/cam2/ then camera 2 and the next as well.

When I use the Website cam.city.travel:4444/cam1/ replayced the address bar in cam.city.travel:4444/cgi-bin/image.html. When I insert /cam1/ ( cam.city.travel:4444/cam1/cgi-bin/image.html ) appears only a part of the page. Examples images are missing.

For the link of the image is cam.city.travel:4444/picture/current.jpg

So far, my idea does not work or is not possible with Varnish?

The following Configuration I use:

    #
    # varnish configuration
    #
    vcl 4.0;

    backend cam01 { .host = "xxx.xxx.xxx.xx1"; .port = "80"; }
    backend cam02 { .host = "xxx.xxx.xxx.xx2"; .port = "80"; }
    backend cam03 { .host = "xxx.xxx.xxx.xx3"; .port = "80"; }
    backend cam04 { .host = "xxx.xxx.xxx.xx4"; .port = "80"; }
    backend cam05 { .host = "xxx.xxx.xxx.xx5"; .port = "80"; }

    sub vcl_recv {
        set req.http.x-host = req.http.host;
        set req.http.x-url = req.url;
        set req.http.x-ip = server.ip;
        set req.http.x-port = std.port(server.ip);

        if (req.http.host == "cam.city.travel:4444") 
          {
           if (req.url ~ "^/cam01/") { set req.url = 
    regsub(req.url, "^/cam01/", "/"); set req.backend_hint = cam01; }
           if (req.url ~ "^/cam02/") { set req.url = 
    regsub(req.url, "^/cam02/", "/"); set req.backend_hint = cam02; }
           if (req.url ~ "^/cam03/") { set req.url = 
    regsub(req.url, "^/cam03/", "/"); set req.backend_hint = cam03; }
           if (req.url ~ "^/cam04/") { set req.url = 
    regsub(req.url, "^/cam04/", "/"); set req.backend_hint = cam04; }
           if (req.url ~ "^/cam05/") { set req.url = 
    regsub(req.url, "^/cam05/", "/"); set req.backend_hint = cam05; }

           set req.http.x-backend = req.backend_hint;
           return (pass);
        }
    }
beatnick33
  • 13
  • 2

1 Answers1

0

It sounds like you could use the round-robin approach with a director, like so:

director cameras round-robin {
        {
                .backend = cam01;
        }
        {
                .backend = cam02;
        }
        {
                .backend = cam03;
        }
        {
                .backend = cam04;
        }
        {
                .backend = cam05;
        }
}

sub vcl_recv {
   if (req.http.host ~ "^cam.city.travel$") {
       set req.backend = cameras;
   }
} 

Ref: https://www.varnish-cache.org/trac/wiki/LoadBalancing

user2182349
  • 9,569
  • 3
  • 29
  • 41
  • Thank you for answer. I will not LoadBalancing. I will direct of the cam. Type I cam.city.travel:4444/cam1/ -> direct to cam1, cam.city.travel:4444/cam2/ -> direct to cam2 ... – beatnick33 Nov 13 '15 at 11:51