Storm UI 內建 Kill Topology 按鈕,若 UI 埠口暴露於外網或內網未授權人員可存取,極易造成生產拓撲被誤殺。本文提供Nginx 反向代理攔截特定 URL方案,零代碼修改、無需重新編譯 Storm,即時生效。
<input onclick="confirmAction('topoId', 'topoName', 'kill', true, 30)" ...>confirmAction 組裝 POST 請求 URL:/topology/{id}/kill/{waitSecs}8080,與 Nimbus Thrift 埠 6627 不衝突,但常與其他服務衝突,建議改 8888。
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;
}
}
# 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 重新編譯打包、升級麻煩、未測試相容性。
allow 10.0.0.0/8; deny all;storm.ui.filter (Storm 1.2+) 內建授權過濾器。nimbus.credential.plugins 驗證提交者身份。