Storm UI 預設提供 Kill Topology 功能,若 UI 位址洩露極易導致拓撲被惡意終止。為保障生產環境穩定,必須屏蔽此功能。本文提供兩種實作方案,推薦使用方案一。
UI 頁面 Kill 按鈕觸發 confirmAction 函式,發送 POST 請求至 /topology/{id}/kill/{waitSecs}。核心邏輯位於 storm-core/src/ui/public/js/script.js。
upstream storm {
server 127.0.0.1:8888 weight=3 max_fails=3 fail_timeout=5s;
}
server {
server_name storm.xxx.com;
listen 80;
proxy_set_header Host $host;
proxy_read_timeout 3600;
proxy_set_header X-Forwarded-For $remote_addr;
access_log /var/log/nginx/storm.access.log main;
error_log /var/log/nginx/storm.error.log debug;
location ~* /topology/(.*)/kill/(.*) {
return 403;
}
location / {
proxy_pass https://storm;
}
}
storm.yaml 設定 ui.port: 8888 並重啟 UI/topology/*/kill/* 請求,直接返回 403編輯 storm-core/src/ui/public/topology.html,移除以下區塊:
<div id="topology-actions"> <h2 class="js-only">Topology actions</h2> <p id="topology-actions" class="js-only"> </p> </div>
此法需重新建構 Storm,生產環境風險較大,暫不建議採用。
方案一透過 Nginx 七層攔截,零侵入式實現功能屏蔽,部署簡單且可隨時回滾,為最佳實踐。