4

我在尝试让 Istio 在我的集群上工作时遇到问题。我的基础架构如下所示:

我有一个 Magento 商店,前面有清漆作为缓存。它在 istio 安装之前工作。我已经启用了特使注入。Varnish 部署在 pod 中,并且有自己的服务重定向未缓存到 magento 服务。

当我尝试从清漆卷曲到 magento 时,问题就来了。

如果我从清漆卷曲 magento 服务,我会重定向到 magento URL(这是预期的行为)

root@varnish-6468d5958d-dvxhx:/# curl -v store-es    
* Rebuilt URL to: store-es/
*   Trying 10.32.97.229...
* TCP_NODELAY set
* Connected to store-es (10.32.97.229) port 80 (#0)
> GET / HTTP/1.1
> Host: store-es
> User-Agent: curl/7.52.1
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< server: envoy
< date: Wed, 07 Nov 2018 11:08:47 GMT
< content-type: text/html
< content-length: 185
< location: https://store-sta.xxxxx.yyy/
< myheader: store-es-6484d46d66-952xj
< x-envoy-upstream-service-time: 4
< 
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.13.8</center>
</body>
</html>
* Curl_http_done: called premature == 0
* Connection #0 to host store-es left intact

但是当我尝试相同但使用 Host 标头跳过 magento 重定向时,我得到了 404:

root@varnish-6468d5958d-dvxhx:/# curl -v -H "Host: store-sta.xxxxx.yyy" store-es    
* Rebuilt URL to: store-es/
*   Trying 10.32.97.229...
* TCP_NODELAY set
* Connected to store-es (10.32.97.229) port 80 (#0)
> GET / HTTP/1.1
> Host: store-sta.xxxxx.yyy
> User-Agent: curl/7.52.1
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< date: Wed, 07 Nov 2018 11:11:59 GMT
< server: envoy
< content-length: 0
< 
* Curl_http_done: called premature == 0
* Connection #0 to host store-es left intact

我已经检查了日志和请求,其中 Host 标头永远不会到达 magento 服务(在我的示例中为 store-es)。当我检查清漆特使的日志是返回 404 的日志时:

[2018-11-07T11:11:50.548Z] "GET /HTTP/1.1" 404 NR 0 0 0 - "-" "curl/7.52.1" "e754b17f-ae2e-4734-beb4-f7a2d6e412da" "store-sta.xxxxx.yyy" "-" - - 10.32.97.229:80 10.32.67.5:45540

你知道为什么会这样吗?为什么主机头在不请求 magento 服务的情况下返回 404?

我还想提一下,magento 在没有清漆的情况下工作,它能够连接到 redis(在同一个集群中)和 mysql(在集群外),所以我已经放弃了 magento 的麻烦。

4

1 回答 1

1

我有一个类似的问题,即主机标头命中特使是一个与内部服务条目名称不匹配的外部域(它永远不会)。由于它不匹配它得到一个 404,我认为必须有一种方法可以使用 VirtualService 配置它,但还不确定如何。

于 2018-12-05T09:35:08.650 回答