curl - Istio 特使正在丢弃带有 Host header 的请求

标签 curl kubernetes virtualhost envoyproxy

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

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

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

如果我从清漆 curl 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 header 跳过 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 header 永远不会到达 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 的麻烦。

最佳答案

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

关于curl - Istio 特使正在丢弃带有 Host header 的请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53188518/

相关文章:

php - Google YouTube API 拒绝将 IP 设置为已接受

curl - 当 curl 或 file_get_contents 请求 https url 时,php-fpm 崩溃

php - 将 webpack devserver (HMR) 与使用虚拟主机运行的 PHP 项目连接起来

node.js - 403禁止+ Nginx +虚拟主机配置+ NodeJS

docker - Kubernetes 持久卷和主机路径

mysql - 具有多个 wordpress 博客的 Apache 虚拟主机

c++ - 执行程序时调用任何 cURL 函数都会导致 "entry point not found"

c# - 在 Web API 上取回 POST 数据

Kubernetes - 如何将信任库路径和密码传递给 JVM 参数

kubernetes - 限制范围中的资源限制和资源最大值有什么区别?请求与分钟?