consul ui访问安全加固

本文侧重介绍访问ui安全加固部分。 安装配置以及集群搭建请参考官方文档

下载安装

官方下载地址&安装教程 Install | Consul | HashiCorp Developer

修改配置,开启acl

首先自行规划好 server和client机器。 按照下述流程在server 生成 bootstrap token。

修改acl 配置如下。default_policy=allow

"acl":{
    "enabled":true,
    "down_policy":"extend-cache",
    "default_policy":"allow",
    "enable_token_persistence" : true,
    "tokens":{
      "default":""
   }

启动 server

# 停止服务 ctl+c 即可。方便调试
consul agent -server -config-dir /opt/consul/conf

生成 global-management

# 另开控制台执行
consul acl bootstrap

获取 SecretID(your_SecretID)

在所有客户端以及当前客户端中 配置 acl

需要更细粒度控制权限,可以后续创建自定义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  &

启动 所有client

  # demo
 consul agent -config-dir /opt/consul/conf > /dev/null 2>&1  &

server 和 client 配置区别

client 不要配置 下述参数

{
   "server":true,
   "bootstrap_expect": 1
}

nginx 安全加固

# 创建用户名为 consul_account 的账号
 htpasswd -c /etc/nginx/consulPwd consul_account # 执行后会要求你输入密码,完了就完成了账号密码的生成
 ```

 ```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 设置只读权限

为了限制 未登录访问 consul ui 的权限,覆盖游客模式使用的 Anonymous Token 的 Policies 即可。

创建 Policies : _Anonymous 形如

session_prefix "" {
    policy = "write"
}

编辑 token: Anonymous Token 修改其 Policies 为 _Anonymous

访问验证

参考

consul安全加固-腾讯云开发者社区-腾讯云

欢迎关注公众号

相关推荐

  1. tomcat安全加固

    2024-04-25 01:48:03       62 阅读
  2. 系统安全加固

    2024-04-25 01:48:03       61 阅读
  3. 系统安全加固

    2024-04-25 01:48:03       34 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-25 01:48:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-25 01:48:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-25 01:48:03       87 阅读
  4. Python语言-面向对象

    2024-04-25 01:48:03       96 阅读

热门阅读

  1. 【PHP】PHP7中的引用计数

    2024-04-25 01:48:03       30 阅读
  2. Innodb 行锁的实现方式及在各隔离级别下的使用

    2024-04-25 01:48:03       35 阅读
  3. [leetcode] 2 的幂

    2024-04-25 01:48:03       33 阅读
  4. Cocos Creator 场景树与组件实例查找详解

    2024-04-25 01:48:03       33 阅读
  5. python

    python

    2024-04-25 01:48:03      29 阅读
  6. 为什么js无法通过contentDocument获取到iframe内容

    2024-04-25 01:48:03       32 阅读
  7. 2024年湖北专升本C语言模拟试卷

    2024-04-25 01:48:03       34 阅读