I have a case where I would like nginx to proxy_pass queries to a backend and mirror it to one or more site.
That is quite straight forward with a config like
server {
server_name mydomain.tld;
listen 80;
location /my/endpoint {
mirror /mirror;
proxy_pass http://mainbackend;
}
location /mirror {
internal;
proxy_pass http://mirrorbackend$request_uri;
}
}
However, the main backend isn't ready yet, and I would like nginx to mirror the query and respond with 200.
I tried the following (and several variation as it didn't work)
server {
server_name mydomain.tld;
listen 80;
location /my/endpoint {
mirror /mirror;
# proxy_pass http://mainbackend;
return 200;
}
location /mirror {
internal;
proxy_pass http://mirrorbackend$request_uri;
}
}
By doing so, nginx do return 200, but mirroring is not working.
I really want nginx to return 200 and not the mirrorbackend response because it's a test server that might be up or down and its state shouldn't impact the response given.
Can it be done ? How can I do that ?