dreamramon
V2EX  ›  问与答

请教一个批量管理 nginx 的实践

  •  
  •   dreamramon · Jun 20, 2023 · 4607 views
    This topic created in 1234 days ago, the information mentioned may be changed or developed.
    手上有 n 台 nginx 要管理,主要是作为反代。。。现在的应用场景:
    一个应用前面有 30 个 nginx ,然后每个 ng 主要是反代不同的规则,现在业务变化要变更,就需要手工登陆上去,一个一个改,改完了 reload ,不知道大家有没有什么更好的方案可以集中式管理,或者通过 api 批量更新的。。。
    注:因为不同的机房,没有上 k8s 。。。
    26 replies  •  2023-06-21 12:40:08 +08:00
    Trim21
    Trim21
    Jun 20, 2023 via Android
    1
    你原本这么原生态都能接受,那我建议你本地改完了 rsync 上去,然后 ssh user@host sudo nginx -s reload…
    v0ker
    v0ker
    Jun 20, 2023
    2
    我们是在 git 上统一管理,配置更新之后上传到仓库,再到机器上拉取代码
    datoujiejie221
    datoujiejie221
    Jun 20, 2023 via iPhone❤️1
    3
    ansible 一把梭
    beshe
    beshe
    Jun 20, 2023
    4
    git 管理版本,jenkins 负责部署
    ik
    ik
    Jun 20, 2023 via iPhone
    5
    没有不同主机上同一个 server_name:port 对应不同业务的情况,就维护一整套配置文件,所有主机同步就行?
    sdwgyzyxy
    sdwgyzyxy
    Jun 20, 2023
    6
    kong ?
    lazyfighter
    lazyfighter
    Jun 20, 2023
    7
    在阿里基于 camel 开发过一版, 我们当时还有 lua 的跨机房路由,青春呀,具体直接 github ,大众点评开源的
    cominghome
    cominghome
    Jun 20, 2023
    8
    1. 起一个仓库管理 nginx conf 目录
    2. 通过 rsync 或者 ansible 分发配置,reload nginx
    crushark
    crushark
    Jun 20, 2023
    9
    Nginx Proxy Manager? 不知道是不是楼主需要的
    https://nginxproxymanager.com/
    yufeng0681
    yufeng0681
    Jun 20, 2023
    10
    写脚本,探测哪个 nginx 的配置修改了,自动进行升级部署
    dolphintwo
    dolphintwo
    Jun 20, 2023
    11
    ansible 一把梭
    johz
    johz
    Jun 20, 2023
    12
    APISIX
    直接在 web 控制台上管理
    wonderblank
    wonderblank
    Jun 20, 2023
    13
    ansible 一把梭
    IDAEngine
    IDAEngine
    Jun 20, 2023
    14
    Jenkins 批量部署
    ytmsdy
    ytmsdy
    Jun 20, 2023
    15
    丢到 Github 上,做个 Action 。发现有 merge 到 main 分支的话,直接触发 action ,全部重新更新一遍。
    onetown
    onetown
    Jun 20, 2023
    16
    ansible 来管理配置和分发吧, 代替你手工修改
    huangzxx
    huangzxx
    Jun 20, 2023
    17
    ansible 一把梭
    dylanninin
    dylanninin
    Jun 20, 2023
    18
    ansible 一般就够了
    zcl0621
    zcl0621
    Jun 20, 2023
    19
    之前做了个工具 ansible 负责推 nginx 配置和 reload
    在网页上编辑和修改配置 管理服务器的密钥地址啥的 管理 nginx 的配置文件等等
    然后一键执行
    感觉挺符合你的要求的。。。 不过项目代码早就没了 都快 5 年了
    surfwave
    surfwave
    Jun 20, 2023
    20
    ansible 一把梭
    learncat
    learncat
    Jun 20, 2023
    21
    @dreamramon nginx 开启 upsync , 统一使用一个 consul 做配置中心, 通过不同的 path 前缀区分 nginx 集群。 实现动态修改。

    后面的 api 的操作,就变成了调用 consul 接口动态写入配置。
    cnoder
    cnoder
    Jun 20, 2023
    22
    jenkins rsync
    apisix
    37Y37
    37Y37
    Jun 20, 2023 via Android
    23
    之前处理过这需求,etcd+confd ,简单 django 写个 webui ,浏览器上就处理了 https://blog.ops-coffee.cn/s/uguvv4jl4yivnztuepdc8a
    yuedanwork
    yuedanwork
    Jun 20, 2023
    24
    Fabric

    个人觉得轻度简单使用的话,1 版本的会比较好用

    [文档 - Fabric 1]( https://www.fabfile.org/installing-1.x.html)

    另外,不是非 nginx 不可的也可以试试 nginx unit 平替,配置可复用,这个可以用 api 管理
    tiezlk443
    tiezlk443
    Jun 21, 2023 via Android
    25
    ansible
    qile1
    qile1
    Jun 21, 2023 via Android
    26
    window 系统下的 nginx 有啥办法管理,有 8 台服务器,每两个多月更新免费 ssl 证书,偶尔更新下配置文件
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2955 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 70ms · UTC 11:18 · PVG 19:18 · LAX 03:18 · JFK 06:18
    ♥ Do have faith in what you're doing.