柚子快報(bào)邀請(qǐng)碼778899分享:consul ui訪問(wèn)安全加固
柚子快報(bào)邀請(qǐng)碼778899分享:consul ui訪問(wèn)安全加固
本文側(cè)重介紹訪問(wèn)ui安全加固部分。 安裝配置以及集群搭建請(qǐng)參考官方文檔
下載安裝
官方下載地址&安裝教程?Install | Consul | HashiCorp Developer
修改配置,開(kāi)啟acl
首先自行規(guī)劃好 server和client機(jī)器。 按照下述流程在server 生成 bootstrap token。
修改acl 配置如下。default_policy=allow
"acl":{
"enabled":true,
"down_policy":"extend-cache",
"default_policy":"allow",
"enable_token_persistence" : true,
"tokens":{
"default":""
}
啟動(dòng) server
# 停止服務(wù) ctl+c 即可。方便調(diào)試
consul agent -server -config-dir /opt/consul/conf
生成 global-management
# 另開(kāi)控制臺(tái)執(zhí)行
consul acl bootstrap
獲取 SecretID(your_SecretID)
在所有客戶端以及當(dāng)前客戶端中 配置 acl
需要更細(xì)粒度控制權(quán)限,可以后續(xù)創(chuàng)建自定義token,替換 default
"acl":{
"enabled":true,
"down_policy":"extend-cache",
"default_policy":"deny",
"enable_token_persistence" : true,
"tokens":{
"default":"your_SecretID"
}
重啟 所有server
# demo
consul agent -server -config-dir /opt/consul/conf > /dev/null 2>&1 &
啟動(dòng) 所有client
# demo
consul agent -config-dir /opt/consul/conf > /dev/null 2>&1 &
server 和 client 配置區(qū)別
client 不要配置 下述參數(shù)
{
"server":true,
"bootstrap_expect": 1
}
nginx 安全加固
# 創(chuàng)建用戶名為 consul_account 的賬號(hào)
htpasswd -c /etc/nginx/consulPwd consul_account # 執(zhí)行后會(huì)要求你輸入密碼,完了就完成了賬號(hào)密碼的生成
```
```conf
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8500;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/consulPwd;
}
}
Anonymous Token 設(shè)置只讀權(quán)限
為了限制 未登錄訪問(wèn) consul ui 的權(quán)限,覆蓋游客模式使用的 Anonymous Token 的 Policies 即可。
創(chuàng)建 Policies : _Anonymous 形如
session_prefix "" {
policy = "write"
}
編輯 token: Anonymous Token 修改其 Policies 為 _Anonymous
訪問(wèn)驗(yàn)證
訪問(wèn)?http://127.0.0.1:8500輸入賬號(hào)密碼
參考
consul安全加固-騰訊云開(kāi)發(fā)者社區(qū)-騰訊云
歡迎關(guān)注公眾號(hào)
柚子快報(bào)邀請(qǐng)碼778899分享:consul ui訪問(wèn)安全加固
相關(guān)鏈接
本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場(chǎng)。
轉(zhuǎn)載請(qǐng)注明,如有侵權(quán),聯(lián)系刪除。