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

关于负载均衡(upstream)的 Host 设置问题 #83

Closed
mzzya opened this issue Jun 19, 2023 · 3 comments
Closed

关于负载均衡(upstream)的 Host 设置问题 #83

mzzya opened this issue Jun 19, 2023 · 3 comments

Comments

@mzzya
Copy link

mzzya commented Jun 19, 2023

map_hash_bucket_size 128;
map $http_host $backend_host {
      default a.**.com;
      a.**.com a.**.com;
      b.**.com b.**.com;
 }
upstream test {
  server a.**.com:80;
  server b.**.com:80;
}
server {
  listen 8082;
  location / {
    proxy_pass http://test;
    proxy_set_header Host $backend_host;
  }
}

如上我们有一组相同功能的后端服务( http header 必须携带对应 host 才能访问),期望请求转发到后端服务器时,服务器收到 host 仍然是 a..com 或者 b..com,应该如何配置?

@cym1102
Copy link
Owner

cym1102 commented Jun 19, 2023 via email

@mzzya
Copy link
Author

mzzya commented Jun 19, 2023

是的

@cym1102
Copy link
Owner

cym1102 commented Jun 19, 2023 via email

@cym1102 cym1102 closed this as completed Jun 25, 2023
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

2 participants