国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

linux系統中 屏蔽storm ui的kill功能的兩種方法

2020-07-10 11:38:52
字體:
來源:轉載
供稿:網友

  今天有個storm的topology被人kill掉了,但是找不到是誰做的,storm的ui有kill topology的功能,但是沒有權限驗證,這樣就導致知道ui地址的任何人都可以kill掉topology,比較危險,考慮把這個action disable掉。

  有兩種方法:

  1.前端增加nginx,做location

  分析ui頁面,對應kill的button,html中的action為:


復制代碼
代碼如下:
  <input enabled="" onclick="confirmAction('xxxxxxxxxx', 'xxxxxxxx', 'kill', true, 30)" type="button" value="Kill">

  調用了js的confirmAction方法,這個方法存在于storm-core/src/ui/public/js/script.js 中,方法的定義如下:


復制代碼
代碼如下:
  function confirmAction(id, name, action, wait, defaultWait) {var opts = {type:'POST',url:'/topology/' + id + '/' + action};
  if (wait) {
  var waitSecs = prompt('Do you really want to ' + action + ' topology "' + name + '"? ' +'If yes, please, specify wait time in seconds:',defaultWait);if (waitSecs != null && waitSecs != "" && ensureInt(waitSecs)) {opts.url += '/' + waitSecs;} else {return false;}
  } else if (!confirm('Do you really want to ' + action + ' topology "' + name + '"?')) {return false;}
  $("input[type=button]").attr("disabled", "disabled");$.ajax(opts).always(function () {window.location.reload();}).fail(function () {alert("Error while communicating with Nimbus.")});return false;}

  以看到方法主要分為兩步,生成post請求的url,格式為'/topology/' + id + '/' + action + '/' + waitSecs,這里action為kill,waitSecs為觸發kill時手動填入的時間,比如這里的30s,最終的url格式如下:


復制代碼
代碼如下:
  /topology/xxxxx/kill/xxxx

  第二步就是根據這個設置觸發一個ajax請求,這里我們只需要關心第一步即可,設置nginx如下:


復制代碼
代碼如下:
  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 http://storm;
  }
  }

  這樣,就可以屏蔽掉前端的kill功能了。

  注意一個細節,storm ui的默認端口時8080,這個端口和nm沖突(見bug https://github.com/yahoo/storm-yarn/issues/25),設置storm.yaml ui.port: 8888,并重啟ui即可.

  2.更改代碼,去掉action相關的button


復制代碼
代碼如下:
  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>

  第二種方法需要重新編譯,還沒有做測試。。

  以上就是linux系統中屏蔽storm ui的kill功能的2種方法,在此感謝本文的原創作者 “菜光光的博客” ,請務必保留此出處http://caiguangguang.blog.51cto.com/1652935/1557514,謝謝閱讀,希望能幫到大家,請繼續關注武林網,我們會努力分享更多優秀的文章。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 定州市| 融水| 兴化市| 教育| 黄冈市| 梁山县| 柘城县| 宣武区| 芜湖县| 根河市| 曲沃县| 宾阳县| 时尚| 平武县| 金平| 东山县| 丰都县| 湾仔区| 班戈县| 台前县| 翁牛特旗| 天祝| 濮阳市| 文安县| 岳阳市| 本溪| 抚顺市| 平舆县| 昌江| 泗洪县| 兰考县| 湘潭县| 防城港市| 彭阳县| 天柱县| 延长县| 阳春市| 顺平县| 长丰县| 无棣县| 麻栗坡县|