【问题标题】:Nginx HTTPS to TCP proxy prepending dataNginx HTTPS 到 TCP 代理前置数据
【发布时间】:2014-08-09 07:46:28
【问题描述】:

我已将 nginx_tcp_proxy_module 设置为代理 xml 发布数据,从 https 连接到我无权访问的第三方服务的 tcp 套接字。

设置工作正常,但似乎某些数据在发送到上游之前已预先添加到原始数据,这导致来自 tcp 服务的响应中出现一些 REQUEST FAILURE 错误。在返回正确的数据之前总是有 6 个 FAILURE 行,这让我觉得正在添加某种标题或内容长度。

有没有办法防止 nginx_tcp_proxy_module 向标头添加任何内容?

我无法看到实际发送到上游的数据(有没有办法让 nginx_tcp_proxy_module 记录它接收到的数据和它发送到上游的数据?)

我在客户端使用请求:

[requests] <---> [nginx https to tcp proxy] <----> [upstream tcp service]

我的请求调用是这样的:

response = requests.post("https://nginx-server.com:port", data="<xml-data-string>", verify="/path/to/certificiate")

我的 nginx 配置:

tcp {   
    access_log  /var/log/nginx/tcp_access.log;

    upstream tcpservice {
            server upstream-server:port;
            check interval=3000 rise=2 fall=5 timeout=1000;
    }

    server {
            listen port;
            server_name nginx-server.com;

            so_keepalive on;
            tcp_nodelay on;

            ssl on;
            ssl_certificate /path/to/cert;
            ssl_certificate_key /path/to/key;
            proxy_pass tcpservice;
    }
}

最后,响应类似于

<REQUEST ERROR>
<REQUEST ERROR>
<REQUEST ERROR>
<REQUEST ERROR>
<REQUEST ERROR>
<REQUEST ERROR>
<CORRECT DATA> <--- Only this should show if the request is fine, as tested by passing the request string directly down the tcp socket.

【问题讨论】:

    标签: sockets nginx tcp proxy


    【解决方案1】:

    我最终使用了 lua 的“content by lua”功能,而不是 nginx_tcp_proxy。我会使用 lua 进行 tcp 调用并通过 nginx 将内容传回。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-03
      • 1970-01-01
      • 2021-04-06
      • 2017-05-16
      相关资源
      最近更新 更多