• 请不要在回答技术问题时复制粘贴 AI 生成的内容
daijinming
V2EX  ›  程序员

请教一个 nginx 根据 HTTP 请求头信息条件转发的问题

  •  
  •   daijinming · Aug 12, 2022 · 2060 views
    This topic created in 1393 days ago, the information mentioned may be changed or developed.
    需求是这样的,一个 HTTP API 请求,如果来源是一个特定的 IP(读取 Referer),不仅要正常返回结果,还需要将这个请求转发给另外一个 API 地址,无需等待返回,请教下大家
    5 replies    2022-08-12 22:39:13 +08:00
    porr
        1
    porr  
       Aug 12, 2022
    用 openresty 加上 lua 应该可以,当然我没有试过具体操作。
    xuelu520
        2
    xuelu520  
       Aug 12, 2022
    nginx Lua 将结果写到消息队列去.
    然后队列那边消费。消费那边转发请求另外那个 api
    neighbads
        3
    neighbads  
       Aug 12, 2022
    自己写一个处理 subrequest 的模块应该能搞
    momocraft
        4
    momocraft  
       Aug 12, 2022
    traffic mirroring ?

    我记得可以无条件 mirror 到 internal location ,然后在 internal location 判断
    xzl
        5
    xzl  
       Aug 12, 2022
    kong
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3021 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 06:08 · PVG 14:08 · LAX 23:08 · JFK 02:08
    ♥ Do have faith in what you're doing.