Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux 屏蔽 Storm UI Kill Topology 功能:Nginx 反向代理攔截方案

編輯:關於 Linux

Storm UI 內建 Kill Topology 按鈕,若 UI 埠口暴露於外網或內網未授權人員可存取,極易造成生產拓撲被誤殺。本文提供Nginx 反向代理攔截特定 URL方案,零代碼修改、無需重新編譯 Storm,即時生效。

Storm UI Kill 請求分析

  • 按鈕 HTML:<input onclick="confirmAction('topoId', 'topoName', 'kill', true, 30)" ...>
  • JS confirmAction 組裝 POST 請求 URL:/topology/{id}/kill/{waitSecs}
  • 預設 UI 埠口 8080,與 Nimbus Thrift 埠 6627 不衝突,但常與其他服務衝突,建議改 8888。

Nginx 攔截配置


upstream storm_ui {
    server 127.0.0.1:8888 weight=3 max_fails=3 fail_timeout=5s;
}

server {
    server_name storm.example.com;
    listen 80;
    # listen 443 ssl; # 若需 HTTPS

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_read_timeout 3600;

    access_log /var/log/nginx/storm.access.log main;
    error_log  /var/log/nginx/storm.error.log warn;

    # 核心攔截規則:匹配 /topology/{id}/kill/{wait} 返回 403
    location ~* /topology/[^/]+/kill/[^/]+ {
        return 403;
        # 或 return 404; 隱藏功能存在性
    }

    # 其餘請求透傳給 Storm UI
    location / {
        proxy_pass https://storm_ui;
    }
}

Storm UI 埠口修改


# conf/storm.yaml
ui.port: 8888
# 重啟 UI
storm ui &
# 或 supervisord 管理

驗證攔截生效


# 正常頁面應可存取
curl -I https://storm.example.com/
# HTTP/1.1 200 OK

# Kill 請求應被攔截
curl -X POST https://storm.example.com/topology/test-topo/kill/30
# HTTP/1.1 403 Forbidden

替代方案:修改前端代碼 (需重新編譯)

編輯 storm-core/src/ui/public/topology.html,移除 <div id="topology-actions"> 區塊。
優點:徹底移除按鈕。
缺點:需 Maven 重新編譯打包、升級麻煩、未測試相容性。

補充安全建議

  • Nginx 層加入 Basic Auth 或 IP 白名單:
    allow 10.0.0.0/8; deny all;
  • 啟用 storm.ui.filter (Storm 1.2+) 內建授權過濾器。
  • Nimbus 啟用 nimbus.credential.plugins 驗證提交者身份。
  • 生產環境嚴禁將 UI 直接暴露於公網。

Storm UI Kill 按鈕截圖

Copyright © Windows教程網 All Rights Reserved