【问题标题】:POCO HttpServer with nginx proxy带有 nginx 代理的 POCO HttpServer
【发布时间】:2011-04-30 17:30:35
【问题描述】:

我最近遇到了POCO project for c++ 并对它很感兴趣。它还有一个我想玩的内置 HttpServer。

我按照示例构建了一个简单的 http 服务器,侦听端口 8000。然后我将我的 nginx 配置为 proxy_pass 所有请求到端口 8000。

使用代理,浏览器将内容大小显示为第一个字符,并在尾部添加 0 个字符。例如,我只使用来自 HttpServer 的“test”字符串进行响应,然后在浏览器端响应为“4 test 0”。当我直接访问端口 8000 时,响应正确显示,没有任何数字。

因为我在使用 nginx 代理时会出现问题,所以我认为我的代理设置有问题。我阅读了 nginx 的 proxy configuration wiki 页面,但不知道为什么会发生这种情况。

我的nginx conf如下,

upstream pocotest {
        server 127.0.0.1:8000;
}

server {
        listen 80;
        server_name localhost;
        location / {
                proxy_pass http://pocotest;
                proxy_set_header X-Real-Ip $remote_addr;
                proxy_buffering on;

                proxy_pass_request_body on;
                proxy_pass_request_headers on;
        }
}

【问题讨论】:

    标签: c++ proxy nginx poco-libraries


    【解决方案1】:

    您得到的是分块编码响应。 4 是内容为“test”的块的长度。分块消息标记末尾的 0。 大多数 likley nginx 没有在响应中添加 Transfer-Encoding: chunked header。

    【讨论】:

      猜你喜欢
      • 2023-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-12
      相关资源
      最近更新 更多