Skip to content

Commit

Permalink
tag 0.01
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoweibin committed Mar 2, 2010
1 parent e23f2db commit f40c8d5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 79 deletions.
44 changes: 21 additions & 23 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,42 @@ Synopsis
# simple round-robin
server 127.0.0.1:3306;
server 127.0.0.1:1234;

# ip_hash
#ip_hash;
}

server {
proxy_connect_timeout 2s;
proxy_pass cluster;
}
}

Description
* TODO

Installation
Grab the nginx source code from nginx.net (<http://nginx.net/>), for
example, the version 0.8.30 (see nginx compatibility), and then build
Download the latest version of the release tarball of this module from
http://github.com/yaoweibin/nginx_tcp_proxy_module.

Grab the nginx source code from nginx.net (<http://nginx.org/>), for
example, the version 0.7.65 (see nginx compatibility), and then build
the source with this module:

$ wget 'http://sysoev.ru/nginx/nginx-0.8.30.tar.gz'
$ tar -xzvf nginx-0.8.30.tar.gz
$ cd nginx-0.8.30/
$ wget 'http://nginx.org/download/nginx-0.7.65.tar.gz'
$ tar -xzvf nginx-0.7.65.tar.gz
$ cd nginx-0.7.65/
$ patch -p1 < /path/to/nginx_tcp_proxy_module/tcp.patch

$ ./configure --add-module=/path/to/nginx_tcp_proxy_module

$ make
$ make install

Download the latest version of the release tarball of this module from

Compatibility
The following versions of Nginx should work with this module:

* 0.8.x (last tested version is 0.8.32)

* 0.7.x >= 0.7.44 (last tested version is 0.7.64)

Earlier versions of Nginx like 0.6.x and 0.5.x will *not* work.

If you find that any particular version of Nginx above 0.7.44 does not
work with this module, please consider reporting a bug.

TODO
* test
* test script
* health check
* failover

Known Issues
* test
Expand All @@ -67,12 +64,13 @@ See Also
* test

Authors
Weibin Yao(姚伟斌) <yaoweibin at gmail dot com>,
Weibin Yao(姚伟斌) <yaoweibin at gmail dot com>

Copyright & License
This README template copy from agentzh(http://github.com/agentzh).

I borrowed a lot of code from upstream and mail module in the nginx 0.7.*
core. This part of code is copyrighted by Igor Sysoev is .
I borrowed a lot of code from upstream and mail module from the nginx 0.7.*
core. This part of code is copyrighted by Igor Sysoev.

This module is licenced under the BSD license.

Expand Down
42 changes: 3 additions & 39 deletions modules/ngx_tcp_proxy_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ typedef struct ngx_tcp_proxy_conf_s {
size_t buffer_size;
ngx_msec_t timeout;

/*support for the variable in the proxy_pass*/
ngx_array_t *proxy_lengths;
ngx_array_t *proxy_values;
} ngx_tcp_proxy_conf_t;
Expand All @@ -23,8 +24,6 @@ static char *ngx_tcp_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static void ngx_tcp_proxy_dummy_read_handler(ngx_event_t *ev);
static void ngx_tcp_proxy_dummy_write_handler(ngx_event_t *ev);
static void ngx_tcp_proxy_handler(ngx_event_t *ev);
/*static void ngx_tcp_proxy_upstream_error(ngx_tcp_session_t *s);*/
/*static void ngx_tcp_proxy_internal_server_error(ngx_tcp_session_t *s);*/
static void *ngx_tcp_proxy_create_conf(ngx_conf_t *cf);
static char *ngx_tcp_proxy_merge_conf(ngx_conf_t *cf, void *parent,
void *child);
Expand Down Expand Up @@ -103,6 +102,7 @@ ngx_module_t ngx_tcp_proxy_module = {
NGX_MODULE_V1_PADDING
};

/*dirty hack*/
void
ngx_tcp_upstream_proxy_generic_handler(ngx_tcp_session_t *s, ngx_tcp_upstream_t *u) {

Expand Down Expand Up @@ -190,6 +190,7 @@ ngx_tcp_proxy_generic_handler(ngx_event_t *rev) {
void
ngx_tcp_proxy_init_session(ngx_connection_t *c, ngx_tcp_session_t *s) {

/*Make the complier happy, maybe use it later.*/
c->read->handler = ngx_tcp_proxy_dummy_write_handler;
c->read->handler = ngx_tcp_proxy_dummy_read_handler;

Expand Down Expand Up @@ -537,43 +538,6 @@ ngx_tcp_proxy_handler(ngx_event_t *ev) {
}
}


/*static void*/
/*ngx_tcp_proxy_upstream_error(ngx_tcp_session_t *s)*/
/*{*/
/*if (s->proxy->upstream->connection) {*/
/*ngx_log_debug1(NGX_LOG_DEBUG_TCP, s->connection->log, 0,*/
/*"close tcp proxy connection: %d",*/
/*s->proxy->upstream->connection->fd);*/

/*ngx_close_connection(s->proxy->upstream->connection);*/
/*}*/

/*if (s->out.len == 0) {*/
/*ngx_tcp_finalize_session(s);*/
/*return;*/
/*}*/

/*s->quit = 1;*/
/*ngx_tcp_send(s->connection->write);*/
/*}*/


/*static void*/
/*ngx_tcp_proxy_internal_server_error(ngx_tcp_session_t *s)*/
/*{*/
/*if (s->proxy->upstream->connection) {*/
/*ngx_log_debug1(NGX_LOG_DEBUG_TCP, s->connection->log, 0,*/
/*"close tcp proxy connection: %d",*/
/*s->proxy->upstream->connection->fd);*/

/*ngx_close_connection(s->proxy->upstream->connection);*/
/*}*/

/*ngx_tcp_finalize_session(s);*/
/*}*/


static char *
ngx_tcp_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
ngx_tcp_proxy_conf_t *pcf = conf;
Expand Down
7 changes: 0 additions & 7 deletions ngx_tcp_core_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,6 @@ ngx_tcp_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
conf->server_name = cf->cycle->hostname;
}

/*if (conf->protocol == NULL) {*/
/*ngx_log_error(NGX_LOG_EMERG, cf->log, 0,*/
/*"unknown tcp protocol for server in %s:%ui",*/
/*conf->file_name, conf->line);*/
/*return NGX_CONF_ERROR;*/
/*}*/

ngx_conf_merge_ptr_value(conf->resolver, prev->resolver, NULL);

return NGX_CONF_OK;
Expand Down
10 changes: 0 additions & 10 deletions ngx_tcp_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ ngx_tcp_init_session(ngx_connection_t *c)
}

if (s->buffer == NULL) {
/*if (ngx_array_init(&s->args, s->pool, 2, sizeof(ngx_str_t))*/
/*== NGX_ERROR)*/
/*{*/
/*ngx_tcp_finalize_session(s);*/
/*return;*/
/*}*/

s->buffer = ngx_create_temp_buf(s->pool, 4096);
if (s->buffer == NULL) {
Expand Down Expand Up @@ -228,10 +222,6 @@ ngx_tcp_send(ngx_event_t *wev)
return;
}

/*if (s->blocked) {*/
/*c->read->handler(c->read);*/
/*}*/

return;
}

Expand Down

0 comments on commit f40c8d5

Please sign in to comment.