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

help request: 尝试代理 hdfs 的 webui,但是会返回 302 重定向,应该如何配置呢?或者是否有示例 #11358

Open
wfy-belief opened this issue Jun 17, 2024 · 2 comments

Comments

@wfy-belief
Copy link

wfy-belief commented Jun 17, 2024

Description

apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: hadoop-route
spec:
  http:
    - name: namenode
      match:
        hosts:
          - example.com
        paths:
          - /hdfs/*
      backends:
        - serviceName: namenode-service
          servicePort: 9870
      plugins:
        - name: proxy-rewrite
          enable: true
          config:
            regex_uri: [ "^/hdfs/(.*)", "/$2" ]
#        - name: response-rewrite
#          enable: true
#          config:
#            status_code: 302
#            # "body": "{\"code\":\"ok\",\"message\":\"new json body\"}"
#            headers:
#              set:
#                X-Server-id: 3
#                X-Server-status: 'on'
#                X-Server-balancer-addr: '$balancer_ip:$balancer_port'
#                Location: example.com/hdfs/
#            vars:
#              - "[ \"status\",\"==\",403 ]"

然后我请求这个路径的 curl 如下

curl example.com/hdfs/ -vl
* Host  example.com:80 was resolved.
* IPv6: (none)
* IPv4: xxxxx
*   Trying xxxx:80...
* Connected to  example.com (xxxx) port 80
> GET /hdfs/ HTTP/1.1
> Host:  example.com
> User-Agent: curl/8.6.0
> Accept: */*
>
< HTTP/1.1 302 Found
< Content-Type: text/plain;charset=utf-8
< Content-Length: 0
< Connection: keep-alive
< Date: Mon, 17 Jun 2024 12:53:07 GMT
< Cache-Control: no-cache
< Expires: Mon, 17 Jun 2024 12:53:07 GMT
< Pragma: no-cache
< X-Content-Type-Options: nosniff
< X-FRAME-OPTIONS: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Location: http:// example.com/index.html
< Server: APISIX/3.9.1
<
* Connection #0 to host  left intact

这个是否只能开发自定义插件解决了呢 QAQ

Environment

  • APISIX version (run apisix version):
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):
@hanqingwu
Copy link
Contributor

个人感觉,可能的两种方法:

1 用apisix 来处理这个302, 添加一条route, 直接把 / 代理到 /index.html
2. 用response_write, 把302的返回,添加你的 “hdfs” 这段代理头

@dyrnq
Copy link
Contributor

dyrnq commented Jul 5, 2024

@wfy-belief 你可以使用 ApisixUpstream 的 healthCheck.active 主动健康检测9870端口的 /isActive 路径,这个在haproxy中很好实现 可以参考https://dyrnq.com/hadoop-namenode-ha/#%e8%a7%a3%e5%86%b3

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

No branches or pull requests

3 participants