我为在kubernetes集群中运行的清漆缓存服务器创建了helm图表,同时使用“外部IP”进行测试会产生其抛出错误,并在下面共享
共享varnish.vcl(在我的情况下为 default.vcl的别名),在下面的values.yaml中。我将后端/ Web服务器硬编码为端口为“ 80”的.host =“ www.varnish-cache.org”时,有关如何解决的任何建议。我的要求是在执行curl -IL负载均衡器入口IP的情况下),我应该使用不如上所述的缓存值(直接从后端服务器)获取响应。
任何解决方案/方法都应解决此问题。请根据我上面的varnish(default.vcl)和values.yaml文件提出任何响应/建议。请将此作为最高优先级。
varnish.vcl:
VCL version 5.0 is not supported so it should be 4.0 or 4.1 even though actually used Varnish version is 6
vcl 4.1;
import std;
# The minimal Varnish version is 5.0
# For SSL offloading, pass the following header in your proxy server or load balancer: 'X-Forwarded-Proto: https'
{{ .Values.varnishconfigData | indent 2 }}
sub vcl_recv {
if(req.url == "/healthcheck") {
return(synth(200,"OK"));
}
}
values.yaml:
# Default values for varnish.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: varnish
tag: 6.3
pullPolicy: IfNotPresent
nameOverride: ""
fullnameOverride: ""
service:
# type: ClusterIP
type: LoadBalancer
port: 80
varnishconfigData: |-
backend default {
.host = "35.170.216.115";
.port = "80";
.first_byte_timeout = 60s;
.connect_timeout = 300s ;
.probe = {
.url = "/";
.timeout = 1s;
.interval = 5s;
.window = 5;
.threshold = 3;
}
sub vcl_backend_response {
set beresp.ttl = 5m;
}
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
path: /
hosts:
- chart-example.local
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources:
limits:
memory: 128Mi
requests:
memory: 64Mi
#resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
答案 0 :(得分:0)
.host =“ www.google.com”;
使用IP地址代替主机名
共享运行命令varnishlog -g request -q“ ReqHeader:Host eq'a2dc15095678711eaae260ae72bc140c-214951329.ap-southeast-1.elb.amazonaws.com”时生成的日志,请在下面使用-q“ ReqUrl eq'/'”看着它。
* << Request >> 1512355
- Begin req 1512354 rxreq
- Timestamp Start: 1584707667.287292 0.000000 0.000000
- Timestamp Req: 1584707667.287292 0.000000 0.000000
- VCL_use boot
- ReqStart 100.112.64.0 51532 a0
- ReqMethod GET
- ReqURL /
- ReqProtocol HTTP/1.1
- ReqHeader Host: 52.220.214.66
- ReqHeader User-Agent: Mozilla/5.0 zgrab/0.x
- ReqHeader Accept: */*
- ReqHeader Accept-Encoding: gzip
- ReqHeader X-Forwarded-For: 100.112.64.0
- VCL_call RECV
- ReqUnset Host: 52.220.214.66
- ReqHeader host: 52.220.214.66
- VCL_return hash
- VCL_call HASH
- VCL_return lookup
- VCL_call MISS
- VCL_return fetch
- Link bereq 1512356 fetch
- Timestamp Fetch: 1584707667.287521 0.000228 0.000228
- RespProtocol HTTP/1.1
- RespStatus 503
- RespReason Backend fetch failed
- RespHeader Date: Fri, 20 Mar 2020 12:34:27 GMT
- RespHeader Server: Varnish
- RespHeader Content-Type: text/html; charset=utf-8
- RespHeader Retry-After: 5
- RespHeader X-Varnish: 1512355
- RespHeader Age: 0
- RespHeader Via: 1.1 varnish (Varnish/6.3)
- VCL_call DELIVER
- RespHeader X-Cache: uncached
- VCL_return deliver
- Timestamp Process: 1584707667.287542 0.000250 0.000021
- Filters
- RespHeader Content-Length: 284
- RespHeader Connection: keep-alive
- Timestamp Resp: 1584707667.287591 0.000299 0.000048
- ReqAcct 110 0 110 271 284 555
- End
** << BeReq >> 1512356
-- Begin bereq 1512355 fetch
-- VCL_use boot
-- Timestamp Start: 1584707667.287401 0.000000 0.000000
-- BereqMethod GET
-- BereqURL /
-- BereqProtocol HTTP/1.1
-- BereqHeader User-Agent: Mozilla/5.0 zgrab/0.x
-- BereqHeader Accept: */*
-- BereqHeader Accept-Encoding: gzip
-- BereqHeader X-Forwarded-For: 100.112.64.0
-- BereqHeader host: 52.220.214.66
-- BereqHeader X-Varnish: 1512356
-- VCL_call BACKEND_FETCH
-- VCL_return fetch
-- FetchError backend default: unhealthy
-- Timestamp Beresp: 1584707667.287429 0.000028 0.000028
-- Timestamp Error: 1584707667.287432 0.000031 0.000002
-- BerespProtocol HTTP/1.1
-- BerespStatus 503
-- BerespReason Service Unavailable
-- BerespReason Backend fetch failed
-- BerespHeader Date: Fri, 20 Mar 2020 12:34:27 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
-- Length 284
-- BereqAcct 0 0 0 0 0 0
-- End