J
J
jwcfree2021-07-02 12:36:25
Nginx
jwcfree, 2021-07-02 12:36:25

How can I add a page response timeout for Nginx Upstream validation?

Let's say there is such a simple upstream.conf configuration

upstream backend {
    server 192.168.1.44:8081;
    server 192.168.1.60:8081;
    server 192.168.1.62:8081;
}

And even simpler nginx configuration
server {
    listen 8081;
    location / {
        proxy_pass http://backend;
    }
}

On port 8081 on each machine, a container with an nginx image runs in the docker, which instead of a welcome page shows the container ID.
Round robin DNS in this case works as expected, when requesting a page, IDs change cyclically.
How can I check the case when the page response timeout appears? Those. artificially create first 10 seconds and check what answer will come. Will 404 errors appear, or will the page take 10 seconds to load, or will the request switch to another IP altogether?
Perhaps there is some ready-made version on fcgi and php-fpm to do something similar?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jwcfree, 2021-07-02
@jwcfree

Once again, many thanks to Lynn "Coffeeman"
With this nginx config inside the container, we managed to do what we intended.
In this case, nginx will wait until the specified timeout expires, if it is set in a particular container.

server {
    listen 80;
    listen [::]:80;

    location / {
        echo_sleep 11;
        default_type 'text/html';
        echo $hostname;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question