Setup nginx not to crash if host in upstream is not found

后端 未结 5 2090
梦谈多话
梦谈多话 2020-11-27 11:20

We have several rails apps under common domain in Docker, and we use nginx to direct requests to specific apps.

our_dev_server.com/foo # proxies to foo app
o         


        
5条回答
  •  星月不相逢
    2020-11-27 12:04

    The main advantage of using upstream is to define a group of servers than can listen on different ports and configure load-balancing and failover between them.

    In your case you are only defining 1 primary server per upstream so it must to be up.

    Instead, use variables for your proxy_pass(es) and remember to handle the possible errors (404s, 503s) that you might get when a target server is down.

提交回复
热议问题