Service discovery at Stripe
Consul is great, but couldn&#x27;t you just simply use NGINX Plus (paid) and utilize the upstream_conf[1], state[2] and healthcheck[3] premium features?<p>Sorry for the long code block below, but it is a full working example that has automatic health checks (adds and removes backends automatically) and a dynamic backend configuration that is persisted to a state file.<p><pre><code>    http {
        proxy_next_upstream error timeout http_502 http_504;

        match statusok {
            status 200;
            body ~ &quot;200 OK&quot;;
        }

        upstream backend {
            state &#x2F;etc&#x2F;nginx&#x2F;backend-state&#x2F;backends;
            zone backend 256k;
            keepalive 20;
        }
    }

    server {
        # dynamic upstream
        location = &#x2F;upstream_conf {
            upstream_conf;
            allow 127.0.0.1;
            deny all;
        }

        location &#x2F; {
            proxy_connect_timeout 15s;
            proxy_http_version 1.1;
            proxy_set_header Connection &quot;&quot;;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;

            proxy_pass http:&#x2F;&#x2F;backend;
        }

        # health check
        location &#x2F;internal-health-check {
            internal;

            proxy_connect_timeout 15s;
            proxy_http_version 1.1;
            proxy_set_header Connection &quot;&quot;;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;

            proxy_pass http:&#x2F;&#x2F;backend;
            health_check interval=3s fails=3 passes=5 uri=&#x2F;health match=statusok;
        }
    }
</code></pre>
[1] - <a href="https:&#x2F;&#x2F;nginx.org&#x2F;en&#x2F;docs&#x2F;http&#x2F;ngx_http_upstream_conf_module.html" rel="nofollow">https:&#x2F;&#x2F;nginx.org&#x2F;en&#x2F;docs&#x2F;http&#x2F;ngx_http_upstream_conf_module...</a><p>[2] - <a href="http:&#x2F;&#x2F;nginx.org&#x2F;en&#x2F;docs&#x2F;http&#x2F;ngx_http_upstream_module.html#state" rel="nofollow">http:&#x2F;&#x2F;nginx.org&#x2F;en&#x2F;docs&#x2F;http&#x2F;ngx_http_upstream_module.html#...</a>
[3] - <a href="http:&#x2F;&#x2F;nginx.org&#x2F;en&#x2F;docs&#x2F;http&#x2F;ngx_http_upstream_module.html#health_check" rel="nofollow">http:&#x2F;&#x2F;nginx.org&#x2F;en&#x2F;docs&#x2F;http&#x2F;ngx_http_upstream_module.html#...</a>