【问题标题】:One Request to the Multiple Nginx Host with Args使用 Args 向多个 Nginx 主机发出一个请求
【发布时间】:2019-04-18 00:31:34
【问题描述】:

我在使用 Nginx 进行后端服务的请求路由时遇到了一点问题。在我的场景中,我有一个前端服务和另一个日志服务,用于记录具有不同请求类型的 404 请求。

---> serviceFrontend/product/productName ----> if 404 ----> serviceLogger?productId=productName

如何在 serviceFrontend 服务触发的同时创建新请求和发送请求。

请帮帮我!


问题的解决

我已经用 nginx 处理了 post_action 注释的问题。

资源:

https://forum.nginx.org/read.php?2,275992,275992

【问题讨论】:

    标签: http nginx lua request microservices


    【解决方案1】:

    您应该有一个 404 错误的自定义错误位置,并通过代理将请求传递到您的上游。您还需要重写模块在查询字符串中设置ProductName。像下面这样:

    location /serviceFrontend/product {
        error_page 404 = @log404;
    }
    
    location @log404 {
        rewrite ^/serviceFrontend/product/(.*)$ /serviceLogger?productId=$1 break;
        proxy_pass http://logger.example.com;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-10
      • 1970-01-01
      • 2016-01-27
      • 2012-06-26
      • 1970-01-01
      • 2013-10-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多