ㄓㄤㄑㄧㄤ

nginx流量复制将请求同时发送到正式和测试环境

业务需求

第三方的回调通知需要发送到生产及测试环境

解决方法

  1. nginx流量复制
  2. 消息队列,一台服务器接收后放入消息队列,需要的服务器订阅消费

考虑到现有项目中没有消息队列,所以使用流量复制实现。后期优化消息队列。

location /{ 
    mirror /mirror;
    proxy_pass http://backend;
}

location /mirror{
    internal;
    proxy_pass http://test_backend$request_uri;
}

处理过程中的问题

1.nginx版本旧,1.13.4以后内置mirror模块。
oneinstack upgrade 命令升级nginx为1.19.0.

2.配置后不生效
多测试几次,多检查几遍配置是否正确。

posted @ 2022-08-25 11:03  ㄓㄤㄑㄧㄤ  阅读(250)  评论(0)    收藏  举报
哈哈,页脚部分。