Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request help: The response head was strangely modified after passing APISIX #4213

Closed
StretchV opened this issue May 11, 2021 · 14 comments
Closed

Comments

@StretchV
Copy link

Issue description

我通过修改本地的hosts对路由在postman上分别做了测试,一种是通过apisix,一种是直接访问后端的ip地址,结果是通过apisix后响应头被不知道什么原因的修改了,下面是不过apisix和过apisix的两种情况
2222222
111111

这是后端往响应头上加头信息的代码:
33333333333

没有开任何的插件,service配的也是穿透模式,不太明白为什么会这样。。

Environment

  • apisix version (cmd: apisix version):apache/apisix:2.3-alpine
@tzssangglass
Copy link
Member

adding Server header to the response header is a default behavior, indicating that the request is handled by APISIX, but overriding Access-Control-Allow-Headers is a problem, what are your upstream services?

@StretchV
Copy link
Author

upstream services is ingress-controller ,I can get the head if I bypass APISIX and visit the upstream

@tzssangglass
Copy link
Member

upstream services is ingress-controller ,I can get the head if I bypass APISIX and visit the upstream

what is the value of Access-Control-Allow-Headers in the request header?

@StretchV
Copy link
Author

这3个是用来cors跨越名访问用的, 还有我之前也有往头里加cache-control: no-cache(清除浏览器缓存)这个过完apisix后也不见了

@Firstsawyou
Copy link
Contributor

This information seems to be carried with the cors plugin enabled. You check if the cors plugin is enabled.
截屏2021-05-11 下午3 09 47

@StretchV
Copy link
Author

是的 谢谢 确实有个全局插件cors!
目前我已经去掉了,而且保证了没有全局插件存在了,但是目前还是有那个响应头丢失的情况存在
1111111
222222

过apisix后cache-control: no-cache没有了..

@StretchV
Copy link
Author

经过测试需要加上插件proxy-cache,并设置hide_cache_headers:false 才能返回给客户端,但是我不太明白为什么会这样呢,这个插件是必须要加的吗?

@Firstsawyou
Copy link
Contributor

The proxy-cache plugin is not necessary, you can provide route related configuration data, I will check it.

@StretchV
Copy link
Author

{
"create_time": 1620454728,
"update_time": 1620454728,
"uris": [
"/bff-message-center",
"/bff-message-center/*"
],
"name": "gateway-test_XXXXXX___bff-message-XXXXXX",
"methods": [
"GET",
"HEAD",
"POST",
"PUT",
"DELETE",
"OPTIONS",
"PATCH"
],
"hosts": [
"gateway-test.XXXXXX"
],
"service_id": "347097464416764780",
"enable_websocket": true,
"status": 1
}
这是这个路由配置, service上只开了prometheus插件

@spacewander
Copy link
Member

@StretchV
the issue is fixed by #3789 in v2.5?

@Firstsawyou
Copy link
Contributor

I confirmed that it has been resolved in APISIX 2.5

@StretchV
Copy link
Author

那我可以先用proxy-cache这个插件配置hide_cache_headers:false 这种方式解决吗,会有什么影响吗,我目前吧这个插件配成全局插件了,我的是2.3版本

@spacewander
Copy link
Member

那我可以先用proxy-cache这个插件配置hide_cache_headers:false 这种方式解决吗,会有什么影响吗,我目前吧这个插件配成全局插件了,我的是2.3版本

This solution looks good to me. If possible, please upgrade to 2.5.

@spacewander
Copy link
Member

Consider solved by #3789

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants