diff options
author | djgel <marcioc.antao@gmail.com> | 2012-06-26 10:45:22 -0300 |
---|---|---|
committer | djgel <marcioc.antao@gmail.com> | 2012-06-26 10:45:22 -0300 |
commit | 715ed2ab3be6921a0ea8dd4ab2851fcf7f769513 (patch) | |
tree | 62e3f33695b3f85bde24bbf649a761544eb3f28d | |
parent | 06a21f139322c56ad322928b5ee3025ac33e3e58 (diff) | |
download | pfsense-packages-715ed2ab3be6921a0ea8dd4ab2851fcf7f769513.tar.gz pfsense-packages-715ed2ab3be6921a0ea8dd4ab2851fcf7f769513.tar.bz2 pfsense-packages-715ed2ab3be6921a0ea8dd4ab2851fcf7f769513.zip |
change req.url and req.http.host to work url to backend :
https://www.varnish-cache.org/docs/master/tutorial/advanced_backend_servers.html
-rw-r--r-- | config/varnish64/varnish.inc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/config/varnish64/varnish.inc b/config/varnish64/varnish.inc index a7009c7d..5dca851c 100644 --- a/config/varnish64/varnish.inc +++ b/config/varnish64/varnish.inc @@ -5,6 +5,7 @@ part of pfSense (http://www.pfSense.com) Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com> Copyright (C) 2011 Marcello Coutinho + Copyright (C) 2012 Marcio Carlos Antão All rights reserved. */ /* ========================================================================== */ @@ -129,8 +130,7 @@ function varnish_get_url_mappings_txt() { if($url['grace']) $directo_grace_time.=($url['grace']=="0s"?"return(pass);":"set req.grace=".$url['grace'].";"); $fieldtype = ($url['fieldtype']?$url['fieldtype']:"=="); - $req=($url['directorurl2']?"url":"http.host"); - $director_prefix=($url['directorurl'] && $url['directorurl2']?"^http://":""); + $director_prefix=($url['directorurl'] && $url['directorurl2']?"^http://":""); #check url if ( $url['directorurl'] || $url['directorurl2'] || $catch_all == "unset" ){ if ( $url['directorurl']== "" && $url['directorurl2']== "" ){ @@ -139,10 +139,19 @@ function varnish_get_url_mappings_txt() { $catch_all = "set"; $isfirst = false; } - else{ + else{ + if(!$isfirst) $urlmappings .= "\telse "; - $urlmappings .= "if (req.$req $fieldtype ".'"'.$url['directorurl'].$url['directorurl2'].'") {'."\n"; + if(!$url['directorurl']) { + $urlmappings .= "if (req.url $fieldtype ".'"^'.$url['directorurl2'].'") {'."\n"; + } + else if (!$url['directorurl2']) { + $urlmappings .= "if (req.http.host $fieldtype ".'"'.$url['directorurl'].'") {'."\n"; + } + else { + $urlmappings .= "if (req.http.host $fieldtype ".'"'.$url['directorurl'].'"'." && req.url $fieldtype ".'"^'.$url['directorurl2'].'") {'."\n"; + } #check failover $urlbackend = "\t\t\tset req.backend = ".$url['directorname'].";"; if ($url['failover'] && $url['failover'] != $url['directorname']){ |