![Nginx 反向代理中继到多个服务器](https://linux22.com/image/718523/Nginx%20%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E4%B8%AD%E7%BB%A7%E5%88%B0%E5%A4%9A%E4%B8%AA%E6%9C%8D%E5%8A%A1%E5%99%A8.png)
我想要将来自 Nginx 的传入请求同时转发到我们的生产服务器和暂存服务器。我该怎么做?
这是我当前的配置:
server {
listen 8000;
proxy_redirect off;
location /mailjet/callback {
post_action @post_for_first_mirroring;
proxy_pass http://www.example.org;
}
location @post_for_first_mirroring {
proxy_pass http://staging.example.org;
proxy_ignore_client_abort on;
return 200;
}
}
但是请求没有到达我的应用程序staging.mydomain.org
。我还能尝试什么?
答案1
镜像模块:
https://nginx.org/en/docs/http/ngx_http_mirror_module.html#mirror
很有用,但是它的使用涉及改变生产配置,并且还会给你的产品 nginx 带来更多的工作,而这两种情况都不是理想的。
此外,有时您希望在将复制的请求发送到非生产环境的过程中对其进行轻微更改。完成从生产环境到另一个环境的实时流量复制所涉及的所有工作的最佳工具是 goreplay: