nginx-0.0.1-2003-11-19-19:26:41 import
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 7a012c8..b7487f8 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -524,22 +524,22 @@
size_t ngx_http_proxy_log_error(void *data, char *buf, size_t len)
{
- ngx_http_proxy_ctx_t *p = data;
+ ngx_http_proxy_log_ctx_t *ctx = data;
ngx_http_request_t *r;
ngx_peer_connection_t *peer;
- r = p->request;
- peer = &p->upstream->peer;
+ r = ctx->proxy->request;
+ peer = &ctx->proxy->upstream->peer;
return ngx_snprintf(buf, len,
" while %s, client: %s, URL: %s, upstream: %s%s%s%s%s",
- p->action,
+ ctx->proxy->action,
r->connection->addr_text.data,
r->unparsed_uri.data,
peer->peers->peers[peer->cur_peer].addr_port_text.data,
- p->lcf->upstream->uri.data,
- r->uri.data + p->lcf->upstream->location->len,
+ ctx->proxy->lcf->upstream->uri.data,
+ r->uri.data + ctx->proxy->lcf->upstream->location->len,
r->args.len ? "?" : "",
r->args.len ? r->args.data : "");
}
@@ -934,7 +934,9 @@
clcf = ctx->loc_conf[ngx_http_core_module.ctx_index];
lcf->upstream->location = &clcf->name;
clcf->handler = ngx_http_proxy_handler;
- clcf->auto_redirect = 1;
+ if (clcf->name.data[clcf->name.len - 1] == '/') {
+ clcf->auto_redirect = 1;
+ }
return NULL;
}
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h
index 0258de5..43eb5ef 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.h
@@ -185,6 +185,12 @@
};
+typedef struct {
+ u_int connection;
+ ngx_http_proxy_ctx_t *proxy;
+} ngx_http_proxy_log_ctx_t;
+
+
#define NGX_HTTP_PROXY_PARSE_NO_HEADER 20
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index 12a4c62..9d442cd 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -210,10 +210,11 @@
{
ngx_http_proxy_ctx_t *p = data;
- ngx_chain_t *cl;
- ngx_http_request_t *r;
- ngx_output_chain_ctx_t *octx;
- ngx_chain_writer_ctx_t *wctx;
+ ngx_chain_t *cl;
+ ngx_http_request_t *r;
+ ngx_output_chain_ctx_t *octx;
+ ngx_chain_writer_ctx_t *wctx;
+ ngx_http_proxy_log_ctx_t *lctx;
r = p->request;
@@ -252,10 +253,17 @@
r->request_hunks = cl;
+ if (!(lctx = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_log_ctx_t)))) {
+ ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
+ lctx->connection = r->connection->number;
+ lctx->proxy = p;
+
p->upstream->peer.log = r->connection->log;
p->saved_ctx = r->connection->log->data;
p->saved_handler = r->connection->log->handler;
- r->connection->log->data = p;
+ r->connection->log->data = lctx;
r->connection->log->handler = ngx_http_proxy_log_error;
p->action = "connecting to upstream";