IT. Expert System.

PHP

Basic VarnishAdmin usage


Basic VarnishAdmin usage

The example illustrates a simple usage of the ban functionality

Example #1 Ban an URL

<?php

$args 
= array(
    
VARNISH_CONFIG_HOST    => "::1",
    
VARNISH_CONFIG_PORT    => 6082,
    
VARNISH_CONFIG_SECRET  => "5174826b-8595-4958-aa7a-0609632ad7ca",
    
VARNISH_CONFIG_TIMEOUT => 300,
);

$va = new VarnishAdmin($args);

try {
    if(!
$va->connect()) {
        throw new 
VarnishException("Connection failed\n");
    }   
} catch (
VarnishException $e) {
    echo 
$e->getMessage();
    exit(
3);
}

try {
    if(!
$va->auth()) {
        throw new 
VarnishException("Auth failed\n");
    }   
} catch (
VarnishException $e) {
    echo 
$e->getMessage();
    exit(
3);
}

try {
    
$status $va->ban('req.url ~ "^/$"');
    if (
VARNISH_STATUS_OK != $status) {
        throw new 
VarnishException("Ban method returned $status status\n");
    }
} catch (
VarnishException $e) {
    echo 
$e->getMessage();
    exit(
3);
}

exit(
0);

?>


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 957 / . Delta: 0.02681 с