summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules/proxy
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/modules/proxy')
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_handler.c16
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_handler.h6
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_upstream.c18
3 files changed, 28 insertions, 12 deletions
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 7a012c88d..b7487f833 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 @@ void ngx_http_proxy_close_connection(ngx_http_proxy_ctx_t *p)
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 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
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 0258de5d8..43eb5ef2d 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 @@ struct ngx_http_proxy_ctx_s {
};
+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 12a4c6232..9d442cd4a 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 @@ static void ngx_http_proxy_init_upstream(void *data)
{
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 @@ ngx_log_debug(r->connection->log, "timer_set: %d" _
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";