溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

linux系統(tǒng)中怎么屏蔽storm ui的kill功能

發(fā)布時(shí)間:2021-07-29 20:39:14 來(lái)源:億速云 閱讀:138 作者:chen 欄目:系統(tǒng)運(yùn)維

本篇內(nèi)容主要講解“l(fā)inux系統(tǒng)中怎么屏蔽storm ui的kill功能”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“l(fā)inux系統(tǒng)中怎么屏蔽storm ui的kill功能”吧!

  今天有個(gè)storm的topology被人kill掉了,但是找不到是誰(shuí)做的,storm的ui有kill topology的功能,但是沒(méi)有權(quán)限驗(yàn)證,這樣就導(dǎo)致知道ui地址的任何人都可以kill掉topology,比較危險(xiǎn),考慮把這個(gè)action disable掉。

  有兩種方法:

  1.前端增加nginx,做location

  分析ui頁(yè)面,對(duì)應(yīng)kill的button,html中的action為:

代碼如下:

  <input enabled="" onclick="confirmAction('xxxxxxxxxx', 'xxxxxxxx', 'kill', true, 30)" type="button" value="Kill">

  調(diào)用了js的confirmAction方法,這個(gè)方法存在于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請(qǐng)求的url,格式為'/topology/' + id + '/' + action + '/' + waitSecs,這里action為kill,waitSecs為觸發(fā)kill時(shí)手動(dòng)填入的時(shí)間,比如這里的30s,最終的url格式如下:

代碼如下:

  /topology/xxxxx/kill/xxxx

  第二步就是根據(jù)這個(gè)設(shè)置觸發(fā)一個(gè)ajax請(qǐng)求,這里我們只需要關(guān)心第一步即可,設(shè)置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功能了。

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

  2.更改代碼,去掉action相關(guān)的button

代碼如下:

  storm-core/src/ui/public/topology.html

  去除掉下面的部分:

代碼如下:

  <div id="topology-actions">
  <h3 class="js-only">Topology actions</h3>
  <p id="topology-actions" class="js-only">
  </p>
  </div>

  第二種方法需要重新編譯,還沒(méi)有做測(cè)試。。

到此,相信大家對(duì)“l(fā)inux系統(tǒng)中怎么屏蔽storm ui的kill功能”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI