Eu sou novo em verniz. Sempre que estou tentando acessar nosso backend via verniz, estou recebendo o erro abaixo: -
<!DOCTYPE html>
<html>
<head>
<title>503 Backend fetch failed</title>
</head>
<body>
<h1>Error 503 Backend fetch failed</h1>
<p>Backend fetch failed</p>
<h3>Guru Meditation:</h3>
<p>XID: 3</p>
<hr>
<p>Varnish cache server</p>
</body>
</html>
Meu varnish.vcl
se parece com o seguinte: -
vcl 4.0;
backend default {
.host = "146.88.25.40";
.port = "8080";
}
Eu também tentei definir .connect_timeout = 60s
, first_byte_timeout = 60s
e .between_bytes_timeout = 60s
mas sem sorte.
Meu /etc/default/varnish
: -
START=yes
NFILES=131072
MEMLOCK=82000
DAEMON_OPTS="-a 0.0.0.0:6081 \
-T localhost:6082 \
-f /etc/varnish/varnish.vcl \
-S /etc/varnish/secret \
-s malloc,1G"
varnishlog
content: -
* << BeReq >> 3
- Begin bereq 2 fetch
- Timestamp Start: 1451466805.152313 0.000000 0.000000
- BereqMethod GET
- BereqURL /rde_server/res/feea8d0b3d50/recomm/home/sid/jb55653bbd980baaf37484ef70bcfcef9b84d7c680ad1b487aed1fb21ac6779025?home_tsFilter=&cat_tsFilter=%28conc.item.brand+not+in+%2836%2C4187%2C4201%2C3721%2C4103%2C4101%2C4199%2C4075%29%29%28conc.item.param1+in+%28+a
- BereqProtocol HTTP/1.1
- BereqHeader User-Agent: curl/7.38.0
- BereqHeader Host: localhost:6081
- BereqHeader Accept: */*
- BereqHeader X-Forwarded-For: ::1
- BereqHeader Accept-Encoding: gzip
- BereqHeader X-Varnish: 3
- VCL_call BACKEND_FETCH
- VCL_return fetch
- FetchError no backend connection
- Timestamp Beresp: 1451466805.152502 0.000189 0.000189
- Timestamp Error: 1451466805.152511 0.000198 0.000009
- BerespProtocol HTTP/1.1
- BerespStatus 503
- BerespReason Service Unavailable
- BerespReason Backend fetch failed
- BerespHeader Date: Wed, 30 Dec 2015 09:13:25 GMT
- BerespHeader Server: Varnish
- VCL_call BACKEND_ERROR
- BerespHeader Content-Type: text/html; charset=utf-8
- BerespHeader Retry-After: 5
- VCL_return deliver
- Storage malloc Transient
- ObjProtocol HTTP/1.1
- ObjStatus 503
- ObjReason Backend fetch failed
- ObjHeader Date: Wed, 30 Dec 2015 09:13:25 GMT
- ObjHeader Server: Varnish
- ObjHeader Content-Type: text/html; charset=utf-8
- ObjHeader Retry-After: 5
- Length 278
- BereqAcct 0 0 0 0 0 0
- End
* << Request >> 2
- Begin req 1 rxreq
- Timestamp Start: 1451466805.152189 0.000000 0.000000
- Timestamp Req: 1451466805.152189 0.000000 0.000000
- ReqStart ::1 44193
- ReqMethod GET
- ReqURL /rde_server/res/feea8d0b3d50/recomm/home/sid/jb55653bbd980baaf37484ef70bcfcef9b84d7c680ad1b487aed1fb21ac6779025?home_tsFilter=&cat_tsFilter=%28conc.item.brand+not+in+%2836%2C4187%2C4201%2C3721%2C4103%2C4101%2C4199%2C4075%29%29%28conc.item.param1+in+%28+a
- ReqProtocol HTTP/1.1
- ReqHeader User-Agent: curl/7.38.0
- ReqHeader Host: localhost:6081
- ReqHeader Accept: */*
- ReqHeader X-Forwarded-For: ::1
- VCL_call RECV
- VCL_return hash
- VCL_call HASH
- VCL_return lookup
- VCL_call MISS
- VCL_return fetch
- Link bereq 3 fetch
- Timestamp Fetch: 1451466805.152650 0.000461 0.000461
- RespProtocol HTTP/1.1
- RespStatus 503
- RespReason Backend fetch failed
- RespHeader Date: Wed, 30 Dec 2015 09:13:25 GMT
- RespHeader Server: Varnish
- RespHeader Content-Type: text/html; charset=utf-8
- RespHeader Retry-After: 5
- RespHeader X-Varnish: 2
- RespHeader Age: 0
- RespHeader Via: 1.1 varnish-v4
- VCL_call DELIVER
- VCL_return deliver
- Timestamp Process: 1451466805.152718 0.000529 0.000068
- RespHeader Content-Length: 278
- Debug "RES_MODE 2"
- RespHeader Connection: keep-alive
- Timestamp Resp: 1451466805.152773 0.000584 0.000055
- ReqAcct 386 0 386 235 278 513
- End
* << Session >> 1
- Begin sess 0 HTTP/1
- SessOpen ::1 44193 :6081 ::1 6081 1451466805.152117 14
- Link req 2 rxreq
- SessClose REM_CLOSE 0.001
- End
Se eu começar o verniz como abaixo, então tudo funciona bem. Eu estou enfrentando o problema apenas quando eu começo o verniz via sudo service varnish start
sudo varnishd -n foo -f /etc/varnish/prudsys.vcl -s malloc,1G -T localhost:6082 -a 0.0.0.0:6081
Tudo funciona bem se adicionar minhas backend
info em /etc/varnish/default.vcl
. Parece que, de alguma forma, o verniz não está escolhendo a configuração atualizada do daemon de /etc/default/varnish
Meu /etc/init.d/varnish
se parece com o seguinte: -
#! /bin/sh
### BEGIN INIT INFO
# Provides: varnish
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start HTTP accelerator
# Description: This script provides a server-side cache
# to be run in front of a httpd and should
# listen on port 80 on a properly configured
# system
### END INIT INFO
# Source function library
. /lib/lsb/init-functions
NAME=varnishd
DESC="HTTP accelerator"
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/varnishd
PIDFILE=/run/$NAME.pid
test -x $DAEMON || exit 0
# Include varnish defaults if available
if [ -f /etc/default/varnish ] ; then
. /etc/default/varnish
fi
# Open files (usually 1024, which is way too small for varnish)
ulimit -n ${NFILES:-131072}
# Maxiumum locked memory size for shared memory log
ulimit -l ${MEMLOCK:-82000}
# If $DAEMON_OPTS is not set at all in /etc/default/varnish, use minimal useful
# defaults (Backend at localhost:8080, a common place to put a locally
# installed application server.)
DAEMON_OPTS=${DAEMON_OPTS:--b localhost}
# Ensure we have a PATH
export PATH="${PATH:+$PATH:}/usr/sbin:/usr/bin:/sbin:/bin"
start_varnishd() {
log_daemon_msg "Starting $DESC" "$NAME"
output=$(/bin/tempfile -s.varnish)
if start-stop-daemon \
--start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- \
-P ${PIDFILE} ${DAEMON_OPTS} > ${output} 2>&1; then
log_end_msg 0
else
log_end_msg 1
cat $output
exit 1
fi
rm $output
}
disabled_varnishd() {
log_daemon_msg "Not starting $DESC" "$NAME"
log_progress_msg "disabled in /etc/default/varnish"
log_end_msg 0
}
stop_varnishd() {
log_daemon_msg "Stopping $DESC" "$NAME"
if start-stop-daemon \
--stop --quiet --pidfile $PIDFILE --retry 10 \
--exec $DAEMON; then
log_end_msg 0
else
log_end_msg 1
fi
if test -r $PIDFILE; then
read -r PID < $PIDFILE
if test ! -d /proc/$PID ; then
# stale pidfile
unset PID
rm -f $PIDFILE
fi
fi
}
reload_varnishd() {
log_daemon_msg "Reloading $DESC" "$NAME"
if /usr/share/varnish/reload-vcl -q; then
log_end_msg 0
else
log_end_msg 1
fi
}
status_varnishd() {
start-stop-daemon \
--status --quiet --pidfile $PIDFILE \
--exec $DAEMON
exit $?
}
configtest() {
$DAEMON ${DAEMON_OPTS} -C -n /tmp 2>/dev/null
if [ "$?" != 0 ]; then
$DAEMON ${DAEMON_OPTS} -C -n /tmp
return $?
fi
}
case "$1" in
start)
case "${START:-}" in
[Yy]es|[Yy]|1|[Tt]|[Tt]rue)
start_varnishd
;;
*)
disabled_varnishd
;;
esac
;;
stop)
stop_varnishd
;;
reload)
reload_varnishd
;;
status)
status_varnishd
;;
restart|force-reload)
if status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}" 1>/dev/null; then
if ! configtest; then
log_failure_msg "Syntax check failed, not restarting"
exit 1
fi
fi
$0 stop
$0 start
;;
configtest)
configtest && log_success_msg "Syntax ok"
;;
*)
log_success_msg "Usage: $0 {start|stop|restart|reload|force-reload|configtest}"
exit 1
;;
esac
Alguém pode me dizer o que está errado? Eu estou usando o varnish 4.1 no Debian 8.