Skip to content

Develop #35

Merged
merged 1 commit into from May 9, 2012

3 participants

@lizc2003
lizc2003 commented May 9, 2012

感谢你贡献的代码,在使用过程中,修改了一些bug,请参考。

lizc2003 修改bug 9d680ad
@yaoweibin
Owner
@lizc2003
lizc2003 commented May 9, 2012

if (pcf->upstream.upstream == NULL) {
ngx_tcp_finalize_session(s);
return;
}
类似这个的改动是在没找到upstream的判断,特别是websocket,这种情况是会发生的。

  • read_bytes = &s->bytes_read;
  • write_bytes = &s->bytes_write;
  • read_bytes = NULL;
  • write_bytes = NULL; 类似这个改动,是access_log的计数有问题,原先的代码,read和write的计数永远相等。

  • s->buffer->pos = s->buffer->start = new_buf;

  • n = s->buffer->pos - s->buffer->start;
  • s->buffer->start = new_buf;
  •        s->buffer->pos = new_buf + n;
    

    这个改动,是因为原来代码把s->buffer->pos丢掉了,在多次收到header头的情况下会出问题。

     n = http_request_parser_execute(hp, (signed char *)s->buffer->start, length, offset);
    
  • s->buffer->pos += n;
  •    s->buffer->pos = s->buffer->start + n;
    

    这个是你理解错http_request_parser_execute的返回值的意思。

    lscf = cscf->access_log = ngx_pcalloc(cf->pool,

  • sizeof(ngx_tcp_core_srv_conf_t));
  •        sizeof(ngx_tcp_log_srv_conf_t));
    

    这个应该是你的笔误

  • ngx_gmtime(t, &tm);

  • ngx_localtime(t, &tm); 这个输出的日志,前面是本地时间, 而gmtime是格林威治时间,不匹配。
@yaoweibin
Owner
@lizc2003
lizc2003 commented May 9, 2012

非常厉害啊,你研究过Nginx的代码?你们在用websocket的功能?
最近我们要用websocket的代理功能,刚好看到你的作品,帮了我们的大忙了,非常感谢!

On 2012/5/9 14:09, lizc2003 wrote:
if (pcf->upstream.upstream == NULL) {
ngx_tcp_finalize_session(s);
return;
}
类似这个的改动是在没找到upstream的判断,特别是websocket,这种情况是会发生的。
这个是在什么情况发生,有类似的出错配置吗?
tcp {
server {
listen 8866 default;
protocol tcp_websocket;
}

server {
    listen 8866;
    server_name xx.xx.com;
    websocket_pass 127.0.0.1:7766;
}

}
这个配置下, 如果域名不匹配,原先代码会崩溃

  • n = s->buffer->pos - s->buffer->start;
  • s->buffer->start = new_buf;
  • s->buffer->pos = new_buf + n; 这个改动,是因为原来代码把s->buffer->pos丢掉了,在多次收到header头的情况下会出问题。 websocket handshake包会多次,我只考虑了一次啊,多次不会出错吗?因为我只 想获取GET的URL地址,然后就发送到后端了?接下来的包都不处理。

Header头如果很大,一次可能发不完啊,这样的话,以前http解释的pos信息就丢了。

@yaoweibin yaoweibin merged commit 30e204a into yaoweibin:develop May 9, 2012
@yaoweibin
Owner
@lizc2003
lizc2003 commented May 9, 2012

我们是做网页游戏的公司,不是互联网这块,:)
另外, 新增了一个添加X-Real-IP头的功能,请参考。
lizc2003@1ece519

@yaoweibin
Owner
@lizc2003
lizc2003 commented May 9, 2012

是的, 项目中用,可以这么粗暴做。这个提交仅仅供你参考。

@yaoweibin
Owner
@bthorman
bthorman commented Jan 3, 2013

I cannot read Chinese, what does it say about websocket_set_header?

@yaoweibin
Owner

He implemented his hardcode version of websocket_set_head. I just don't like and decline it.

If you want to use the websocket proxy, I suggest you use the official version in future. As the official Nginx team will add this feature in the first season of 2013 (http://trac.nginx.org/nginx/roadmap ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.