跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 快速切换 Nginx 的 upstream 有正确的姿势吗?
未分類
15 7 月 2020

快速切换 Nginx 的 upstream 有正确的姿势吗?

快速切换 Nginx 的 upstream 有正确的姿势吗?

資深大佬 : saytesnake 7

upstream foo {  server 127.0.0.1:8081; }  upstream foo_back {  server 127.0.0.1:8080; }  upstream bar {  server 127.0.0.2:8081; }  upstream bar_back {  server 127.0.0.2:8080; }  localtion / {  proxy_pass http://foo; }  localtion /back {  proxy_pass http://foo_back; } 

要切换到 bar 就要修改 proxy_pass 里面的,如果实际情况是很多 upstream,很多 localtion,有什么插件或是 lua 之类的可以实现快捷切换吗?

大佬有話說 (4)

  • 資深大佬 : Jirajine

    你可能需要 treafik
    https://containo.us/traefik/

  • 資深大佬 : halfcrazy

    lua 变量替代 proxy_pass 里写死的 upstream
    set $backend “default”;
    rewrite_by_lua_block {
    ngx.var.backend=”foo”
    }
    proxy_pass http://backend;

  • 資深大佬 : des

    看一下这个?
    http://nginx.org/en/docs/http/ngx_http_upstream_conf_module.html
    http://nginx.org/en/docs/http/ngx_http_api_module.html

  • 資深大佬 : monkeyNik

    可以参考:Github 的 yzprofile/ngx_http_dyups_module,可以动态增加、删除、更新 upstream
    或者也可以考虑是用 nginx.zone 这个网站上面的 Nginx 发行版,提供了不仅仅是动态 upstream 更新,也提供了动态 location 更新,无需 reload 。也提供了各种其他功能,基本全部指令对动态 location 支持。

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具