apisix icon indicating copy to clipboard operation
apisix copied to clipboard

request help: why the location in response header that returned by APISIX has the 9443 port?

Open shuoshadow opened this issue 4 years ago • 25 comments

Issue description

apisix前使用slb 443端口转发到apisix的9443端口 apisix 代理https请求后 携带了9443端口导致无法重定向 image

是因为header的原因吗?我配置了apisixroute的proxy-rewrite插件也不行

    - name: proxy-rewrite
      enable: true
      config:
        headers:
          "Host": $host

Environment

  • your apisix-ingress-controller version (output of apisix-ingress-controller version --long);
  • your Kubernetes cluster version (output of kubectl version);
  • if you run apisix-ingress-controller in Bare-metal environment, also show your OS version (uname -a).

shuoshadow avatar Jun 02 '21 05:06 shuoshadow

@shuoshadow Which action results in this redirect? Is this a behavior of APISIX itself or its backend?

tokers avatar Jun 02 '21 09:06 tokers

Can you provide more detailed information?

tao12345666333 avatar Mar 23 '22 05:03 tao12345666333

I have encountered a similar situation kubernetes svc Access normal 6NQERMQMV@{WH G}V(CW(CD

apisixroute

6NQERMQMV@{WH G}V(CW(CD

wangyp0701 avatar Apr 25 '22 08:04 wangyp0701

This is an already known problem, see https://github.com/apache/apisix/pull/6686.

tokers avatar Apr 25 '22 08:04 tokers

https://github.com/apache/apisix/issues/6286#issuecomment-1040016759 This is not the best way

wangyp0701 avatar Apr 26 '22 08:04 wangyp0701

https://github.com/apache/apisix/issues/6945 proxy-rewrite cannot modify X-Forwarded-Port same problem as mine

Horus-K avatar Apr 27 '22 04:04 Horus-K

@shuoshadow Temporary workaround: Change the apisix port to 80 443

Horus-K avatar Apr 28 '22 02:04 Horus-K

Or should apache apisix handle the port in redirect url by using the X-Forwarded-Port?

tokers avatar Apr 28 '22 09:04 tokers

Or should apache apisix handle the port in redirect url by using the X-Forwarded-Port?

+1.

ref: #6945

tzssangglass avatar Apr 28 '22 13:04 tzssangglass

https://apisix.apache.org/docs/apisix/plugins/redirect#example-usage

set apisix config.yaml

... ssl: enable: true enable_http2: true listen_port: 443 ...

will redirect 443 port

snksos avatar Jul 04 '22 06:07 snksos

Was this fixed on recent releases? Whats the recommended way going forward for this issue?

vvavepacket avatar Jan 26 '23 01:01 vvavepacket

Was this fixed on recent releases? Whats the recommended way going forward for this issue?

What's your version? Recent releases will check the X-Forwarded-Port header, so the redirect will be correct.

tokers avatar Jan 27 '23 11:01 tokers

I am using the last available version of the apisix helm chart with default option. When i try to access the keycloak admin console, APISIX redirects me as follows: https://keycloak.mydomain.com:9443/admin/

Can you please give us the way to fix this please ?

fbossiere avatar Feb 05 '23 17:02 fbossiere

@fbossiere Without a context, I didn't know if this is an issue or a normal scene.

tokers avatar Feb 06 '23 02:02 tokers

The context is very simple.

1- You deploy apisix ingress controller on any 1.2x k8s cluster using the official documentation with default values yaml, then 2- you helm install keycloak with default values.yaml, together with 3- a standard apisix route + certificate

Then you notice that this weird redirection occurs when you try to access the admin console of keycloak.

Something is clearly going wrong with the X-forwarded-port but nothing in apisix-ingress-controller documentation tells us how to fix.

This problem doesn't occur with nginx ingress controller, nor traefik. It basically has been preventing our company to use apisix until now.

Le lun. 6 févr. 2023, 03:19, Alex Zhang @.***> a écrit :

@fbossiere https://github.com/fbossiere Without a context, I didn't know if this is an issue or a normal scene.

— Reply to this email directly, view it on GitHub https://github.com/apache/apisix/issues/6954#issuecomment-1418400843, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEG6MNEZPOHP7OX2DHN6CSTWWBNRRANCNFSM5UQ3JGZA . You are receiving this because you were mentioned.Message ID: @.***>

fbossiere avatar Feb 06 '23 04:02 fbossiere

a quick fix for this is setting the HTTPS port to 443 via the field: https://github.com/apache/apisix-helm-chart/blob/master/charts/apisix/values.yaml#L192.

tokers avatar Feb 06 '23 08:02 tokers

@fbossiere If this is OK for you, would you like to submit a PR to mention it in the docs?

tokers avatar Feb 06 '23 08:02 tokers

Due to lack of the reporter's response this issue has been labeled with "no response". It will be close in 3 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Aug 08 '23 10:08 github-actions[bot]

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.

github-actions[bot] avatar Aug 11 '23 10:08 github-actions[bot]

"Has anyone fixed this issue? I am experiencing the same problem."

lkad avatar Oct 22 '24 06:10 lkad

a quick fix for this is setting the HTTPS port to 443 via the field: https://github.com/apache/apisix-helm-chart/blob/master/charts/apisix/values.yaml#L192.

This configuration has the load balancer port set to 443, but if the port inside the container is 9443, it will still redirect to 9443.

lkad avatar Oct 22 '24 06:10 lkad

+1

vinson-zhang avatar May 22 '25 07:05 vinson-zhang

+1

Eifoen avatar Sep 12 '25 12:09 Eifoen

Due to lack of the reporter's response this issue has been labeled with "no response". It will be close in 3 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Nov 14 '25 10:11 github-actions[bot]

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.

github-actions[bot] avatar Nov 18 '25 10:11 github-actions[bot]