V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
nikoo
V2EX  ›  问与答

Nginx 是否可以配置多个 proxy_pass?

  •  
  •   nikoo · 2017-08-26 22:27:11 +08:00 · 1865 次点击
    这是一个创建于 2446 天前的主题,其中的信息可能已经有所发展或是发生改变。
    现有配置
    location / {
      proxy_pass http://server_1;
    }

    目前需要配置在 http://server_1 挂掉时(返回非 200 值)去尝试获取 http://server_2

    是否可以实现?
    5 条回复    2017-08-26 22:43:35 +08:00
    mx1700
        1
    mx1700  
       2017-08-26 22:31:48 +08:00 via Android   ❤️ 1
    搜索 nginx upstream
    virusdefender
        2
    virusdefender  
       2017-08-26 22:33:36 +08:00   ❤️ 1
    upstream 健康检查
    undeflife
        3
    undeflife  
       2017-08-26 22:34:14 +08:00   ❤️ 2
    upstream up_nodes {
    server xx.xx.xx.xx:80 max_fails=0;
    server xx.xx.xx.xx:80 max_fails=0;
    keepalive 64;
    }

    server {
    proxy_next_upstream error timeout http_500 http_502 http_503 http_504;
    location / {
    proxy_pass http://up_nodes;
    break;
    }
    }
    terrawu
        4
    terrawu  
       2017-08-26 22:38:33 +08:00
    caddy 吧,nginx 免费版纯靠配置做些有 load balance, failover, healthcheck 事情是力不从心的。haproxy 也行。
    gclove
        5
    gclove  
       2017-08-26 22:43:35 +08:00
    upstream 就是用来做负载均衡方面的事情的. 你可以百度一下 upstream 的功能
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1062 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 19:28 · PVG 03:28 · LAX 12:28 · JFK 15:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.