W
W
Webber2021-03-12 10:08:56
Nginx
Webber, 2021-03-12 10:08:56

How to duplicate a request to 2 servers?

There is a location that sends api to php.
Task: you need to make this request sent to 2 servers at once (not balancing, but a double).

location ~ ^/backend/api/event(.*) {
        set $upstream 111.111.111.111:9000;

        rewrite ^/backend/(.*)$ /$1 break;
        fastcgi_pass $upstream;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /code/web/app.php;
        fastcgi_param REQUEST_URI $uri$is_args$args;
    }


Moreover, for the first server:
fastcgi_param SCRIPT_FILENAME /code/web/app.php;

For the second:
fastcgi_param SCRIPT_FILENAME /var/www/public/index.php;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2021-03-12
@AKLZephyr

nginx.org/en/docs/http/ngx_http_mirror_module.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question