测试linkerd的服务时使用postman会出错,解析不到正确的host
协议是http,curl,java用unirest模拟http(和postman相同的参数,代码也是postman生成的)都行,就是postman不行(No hosts are available for /svc/localhost:4140)
public static void main(String[] args) throws Exception{
HttpResponse<String> response = Unirest.get("http://localhost:4140/")
.header("GET", "/6767 HTTP/1.1")
.header("cache-control", "no-cache")
.header("host", "web")
.header("postman-token", "4def4acc-61ad-d443-9ce5-52a3df3db501")
.asString();
System.out.println(response.getBody());
}
curl -H "Host: web" http://localhost:4140/
后来google发现,原理是postman会屏蔽一些header的修改,在get时,设置header(Host:web)没有起作用。需要安装postman interceptor或者打开postman interceptor开关,这时设置的header才能起作用
查找结果:
Override the ‘Host’ header #781
Interceptor extension 下面Restricted Headers
enjoy service mesh!