Skip to main content
Inspiring
May 9, 2012
Question

Varnish Config for Failover

  • May 9, 2012
  • 2 replies
  • 2684 views

Is there any example VCL configuration for reverse proxying FMS 4.5, including examples of how to handle live stream failover features in 4.5.2? The documentation for FMS does not provide anything other than saying it is possible.  http://help.adobe.com/en_US/flashmediaserver/configadmin/WS418c3323187a5d5740d39080135d5593e08-8000.html#WS418c3323187a5d5740d39080135d5593e08-7ffe)

This topic has been closed for replies.

2 replies

Inspiring
January 15, 2013

Here is a nice article written by Adobe Media Server team member on writing a basic varnish configuration script to configure Varnish for the failover solution.

http://www.adobe.com/devnet/adobe-media-server/articles/varnish-sample-for-failover.html


Adobe Employee
May 12, 2012

Actually did not get your query clearly. Are you saying our documentation is not good enough for you to use the Failover feature? if yes please let us know - but i do not think that's the case here or i might be missing something.

If you are asking we should document how does one go about configure proxy as reverse proxy - i think that documentation you should be able to find over internet - let me know if this what you were asking or if i did not get your query right?

Inspiring
May 21, 2012

The documentation is vague at best. Do we have to write a separate script to parse the control plane XML, and disable the stream if somethign is wrong, and separately configure the reverse proxy to change the backend when the backend is unhealthy?

Surely there are some simple samples developed in-house by Adobe that could be shared? I'm not expecting a complete varnish configuration, just a snippet of what is expected to get HTTP Streaming Failover to work.

May 22, 2012

Hey Michael,

Right now we are in a process of getting the documents updated with sample configurations. Meanwhile, I will just provide you with some links that can be helpful in setting up your failover system.

For configuring Http Failover, you can configure two different backends -

## define backends:

backend b1 {}

backend b2{} and specify the url, timeout and host properties for each.

You can define the nature of your switch overs between different packagers using varnish directors like round robin, random etc.

director red round-robin {

    {.backend = b1;}

    {.backend = b2;}

}

Your own logic of what happens when the proxy receives a request from the client goes inside -

sub vcl_recv {

   

    if (req.restarts == 0) {

       set req.backend = red;

    }

  else if (req.restarts == 1) {

       set req.backend = b2;

   }

  else {

       error 404 "Not Found";

  }

}

The req.restart is handled by varnish internally and changed whenever a 503 or an unresponsive code is received by varnish from any of the configured backends.

Handle errors -

sub vcl_error {

    if (obj.status == 404) {

        set obj.http.Content-Type = "text/html; charset=utf-8";

        set obj.response = "Not Found";

        synthetic {"

            <?xml version="1.0" encoding="utf-8"?>

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

            <html>

                <head>

                    <title>"} + obj.status + " " + obj.response + {"</title>

                </head>

                <body>

                    <h1>Error "} + obj.status + " " + obj.response + {"</h1>

                    <p>"} + obj.response + {"</p>

                    <h3>Guru Meditation:</h3>

                    <p>XID: "} + req.xid + {"</p>

                    <address><a href="http://www.varnish-cache.org/">Varnish</a></address>

                </body>

            </html>

        "};

       

        return(deliver);

    }

}

You can consult the varnish documents for details of handling delivery,error handling and cache logic.

For a complete example for failover, refer this link.

I hope this gets you started in the right directions.