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

after nginx reset Host Header, the VirtualService rule will be failure #41709

Closed
wang-xiaowu opened this issue Nov 1, 2022 · 3 comments
Closed

Comments

@wang-xiaowu
Copy link

wang-xiaowu commented Nov 1, 2022

Bug Description

server {
    listen       80;
    listen  [::]:80;
    server_name  _;
    proxy_set_header Host $http_host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Host $server_name;
    proxy_http_version 1.1;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        #root   /usr/share/nginx/html;
        #index  index.html index.htm;
        proxy_pass http://testaaa:31000;
    }
    location /baidu {
        #root   /usr/share/nginx/html;
        #index  index.html index.htm;
        proxy_pass http://www.baidu.com/;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

this is my nginx config

and when i try to curl nginx with header-a, i wish it can be routing to testaaa's header-a version

but it did not work

when i delete this row proxy_set_header Host $http_host;, it worked, i think It's chaotic with the VirtualService's hosts column, but i need this row, so how can i figure this out

Version

istio version: 1.14.1

Client Version: v1.24.4+k3s1
Kustomize Version: v4.5.4
Server Version: v1.24.4+k3s1

Additional Information

No response

@escoffier
Copy link
Contributor

What's the problem with virtualservice?

@wang-xiaowu
Copy link
Author

wang-xiaowu commented Nov 2, 2022

What's the problem with virtualservice?

thanks for your answer

i config proxy_set_header Host $http_host; in my nginx, it effect the virtualservice router

this is my virtual service

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: api-open-service
  namespace: sopei-biz
spec:
  hosts:
  - api-open-service.sopei-biz.svc.cluster.local
  http:
  - match:
    - headers:
        project-version:
          exact: master
    route:
    - destination:
        host: api-open-service.sopei-biz.svc.cluster.local
        subset: master
  - route:
    - destination:
        host: api-open-service.sopei-biz.svc.cluster.local
        subset: master

so my question is, what can i do if i dont want to change my Host header

@wang-xiaowu
Copy link
Author

Provisionally i reset the config to this, to support several host

  - api-open-service.sopei-biz.svc.cluster.local
  - ${host which i wanna}

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

No branches or pull requests

3 participants