mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
nginx-0.1.15-RELEASE import
*) Bugfix: the error while the connecting to the FastCGI server caused segmentation fault. *) Bugfix: the correct handling of the regular expression, that has different number of the captures and substitutions. *) Feature: the location, that is passed to the FastCGI server, can be regular expression. *) Bugfix: the FastCGI's parameter REQUEST_URI is now passed with the arguments and in the original state. *) Bugfix: the ngx_http_rewrite_module module was required to be built to use the regular expressions in locations. *) Bugfix: the directive "proxy_preserve_host on" adds port 80 to the "Host" headers, if upstream listen on port 80; the bug had appeared in 0.1.14. *) Bugfix: the same paths in autoconfiguration parameters --http-client-body-temp-path=PATH and --http-proxy-temp-path=PATH, or --http-client-body-temp-path=PATH and --http-fastcgi-temp-path=PATH caused segmentation fault.
This commit is contained in:
parent
fbf4fc0da9
commit
3259e85b7a
@ -2,7 +2,7 @@
|
|||||||
# Copyright (C) Igor Sysoev
|
# Copyright (C) Igor Sysoev
|
||||||
|
|
||||||
|
|
||||||
if [ $USE_PCRE = YES ]; then
|
if [ $USE_PCRE = YES -o $PCRE != NONE ]; then
|
||||||
. auto/lib/pcre/conf
|
. auto/lib/pcre/conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -32,6 +32,10 @@ http {
|
|||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# deny access to .htaccess files
|
||||||
|
#
|
||||||
|
#location ~ \.ht {
|
||||||
|
# deny all;
|
||||||
|
#}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,94 @@
|
|||||||
title="nginx">
|
title="nginx">
|
||||||
|
|
||||||
|
|
||||||
|
<changes ver="0.1.15" date="19.01.2005">
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
ÏÛÉÂËÁ ÓÏÅÄÉÎÅÎÉÑ Ó FastCGI-ÓÅÒ×ÅÒÏÍ ×ÙÚÙ×ÁÌÁ segmentation fault.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the error while the connecting to the FastCGI server caused
|
||||||
|
segmentation fault.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
ËÏÒÒÅËÔÎÁÑ ÏÂÒÁÂÏÔËÁ ÒÅÇÕÌÑÒÎÏÇÏ ×ÙÒÁÖÅÎÉÑ, × ËÏÔÏÒÏÍ ÞÉÓÌÏ
|
||||||
|
×ÙÄÅÌÅÎÎÙÈ ÞÁÓÔÅÊ ÎÅ ÓÏ×ÐÁÄÁÅÔ Ó ÞÉÓÌÏÍ ÐÏÄÓÔÁÎÏ×ÏË.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the correct handling of the regular exporession, that
|
||||||
|
has different number of the captures and substitutions.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="feature">
|
||||||
|
<para lang="ru">
|
||||||
|
location, ËÏÔÏÒÙÊ ÐÅÒÅÄÁ£ÔÓÑ FastCGI-ÓÅÒ×ÅÒÕ, ÍÏÖÅÔ ÂÙÔØ ÚÁÄÁÎ
|
||||||
|
Ó ÐÏÍÏÝØÀ ÒÅÇÕÌÑÒÎÏÇÏ ×ÙÒÁÖÅÎÉÑ.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the location, that is passed to the FastCGI server, can be
|
||||||
|
regualar expression.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
ÐÁÒÁÍÅÔÒ FastCGI REQUEST_URI ÔÅÐÅÒØ ÐÅÒÅÄÁ£ÔÓÑ ×ÍÅÓÔÅ Ó ÁÒÇÕÍÅÎÔÁÍÉ
|
||||||
|
É × ÔÏÍ ×ÉÄÅ, × ËÏÔÏÒÏÍ ÂÙÌ ÐÏÌÕÞÅÎ ÏÔ ËÌÉÅÎÔÁ.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the FastCGI's parameter REQUEST_URI is now passed with the arguments
|
||||||
|
and in the original state.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
ÄÌÑ ÉÓÐÏÌØÚÏ×ÁÎÉÑ ÒÅÇÕÌÑÒÎÙÈ ×ÙÒÁÖÅÎÉÊ × location ÎÕÖÎÏ ÂÙÌÏ
|
||||||
|
ÓÏÂÉÒÁÔØ nginx ×ÍÅÓÔÅ Ó ngx_http_rewrite_module.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the ngx_http_rewrite_module module was required to be built to use
|
||||||
|
the regular expressions in locations.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
ÅÓÌÉ ÂÜËÅÎÄ ÓÌÕÛÁÌ ÎÁ 80-ÏÍ ÐÏÒÔÕ, ÔÏ ÐÒÉ ÉÓÐÏÌØÚÏ×ÁÎÉÉ ÄÉÒÅËÔÉ×Ù
|
||||||
|
<nobr>"proxy_preserve_host on"</nobr> × ÚÁÇÏÌÏ×ËÅ "Host" ÕËÁÚÙ×ÁÌÓÑ
|
||||||
|
ÔÁËÖÅ ÐÏÒÔ 80;
|
||||||
|
ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.14.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the directive <nobr>"proxy_preserve_host on"</nobr> adds port 80
|
||||||
|
to the "Host" headers, if upstream listen on port 80;
|
||||||
|
bug appeared in 0.1.14.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
ÅÓÌÉ ÚÁÄÁÔØ ÏÄÉÎÁËÏ×ÙÅ ÐÕÔÉ × ÐÁÒÁÍÅÔÒÁÈ Á×ÔÏËÏÎÆÉÇÕÒÁÃÉÉ
|
||||||
|
--http-client-body-temp-path=PATH É --http-proxy-temp-path=PATH
|
||||||
|
ÉÌÉ --http-client-body-temp-path=PATH É --http-fastcgi-temp-path=PATH,
|
||||||
|
ÔÏ ÐÒÏÉÓÈÏÄÉÌ segmentation fault.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the same pathes in autoconfiguration paramters
|
||||||
|
--http-client-body-temp-path=PATH and --http-proxy-temp-path=PATH,
|
||||||
|
or --http-client-body-temp-path=PATH nad --http-fastcgi-temp-path=PATH
|
||||||
|
caused segmentation fault.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
</changes>
|
||||||
|
|
||||||
|
|
||||||
<changes ver="0.1.14" date="18.01.2005">
|
<changes ver="0.1.14" date="18.01.2005">
|
||||||
|
|
||||||
<change type="feature">
|
<change type="feature">
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#define _NGINX_H_INCLUDED_
|
#define _NGINX_H_INCLUDED_
|
||||||
|
|
||||||
|
|
||||||
#define NGINX_VER "nginx/0.1.14"
|
#define NGINX_VER "nginx/0.1.15"
|
||||||
|
|
||||||
#define NGINX_VAR "NGINX"
|
#define NGINX_VAR "NGINX"
|
||||||
#define NGX_NEWPID_EXT ".newbin"
|
#define NGX_NEWPID_EXT ".newbin"
|
||||||
|
@ -252,9 +252,19 @@ ngx_int_t ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot)
|
|||||||
for (n = 0; n < 3; n++) {
|
for (n = 0; n < 3; n++) {
|
||||||
if (p[i]->level[n] != path->level[n]) {
|
if (p[i]->level[n] != path->level[n]) {
|
||||||
if (path->conf_file == NULL) {
|
if (path->conf_file == NULL) {
|
||||||
|
if (p[i]->conf_file == NULL) {
|
||||||
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||||
|
"the default path name \"%V\" has "
|
||||||
|
"the same name as another default path, "
|
||||||
|
"but the different levels, you need to "
|
||||||
|
"redefine one of them in http section",
|
||||||
|
&p[i]->name);
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||||
"the path name \"%V\" in %s:%ui has "
|
"the path name \"%V\" in %s:%ui has "
|
||||||
"the same name as default path but "
|
"the same name as default path, but "
|
||||||
"the different levels, you need to "
|
"the different levels, you need to "
|
||||||
"define default path in http section",
|
"define default path in http section",
|
||||||
&p[i]->name, p[i]->conf_file, p[i]->line);
|
&p[i]->name, p[i]->conf_file, p[i]->line);
|
||||||
|
@ -79,16 +79,28 @@ ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ngx_uint_t ngx_regex_capture_count(ngx_regex_t *re)
|
||||||
|
{
|
||||||
|
int rc, n;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
|
||||||
|
rc = pcre_fullinfo(re, NULL, PCRE_INFO_CAPTURECOUNT, &n);
|
||||||
|
|
||||||
|
return (ngx_uint_t) n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s,
|
ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s,
|
||||||
int *matches, ngx_int_t size)
|
int *captures, ngx_int_t size)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = pcre_exec(re, NULL, (const char *) s->data, s->len, 0, 0,
|
rc = pcre_exec(re, NULL, (const char *) s->data, s->len, 0, 0,
|
||||||
matches, size);
|
captures, size);
|
||||||
|
|
||||||
if (rc == -1) {
|
if (rc == -1) {
|
||||||
return NGX_DECLINED;
|
return NGX_REGEX_NO_MATCHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include <pcre.h>
|
#include <pcre.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define NGX_REGEX_NO_MATCHED -1000
|
||||||
|
|
||||||
#define NGX_REGEX_CASELESS PCRE_CASELESS
|
#define NGX_REGEX_CASELESS PCRE_CASELESS
|
||||||
|
|
||||||
typedef pcre ngx_regex_t;
|
typedef pcre ngx_regex_t;
|
||||||
@ -21,8 +23,9 @@ typedef pcre ngx_regex_t;
|
|||||||
void ngx_regex_init();
|
void ngx_regex_init();
|
||||||
ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options,
|
ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options,
|
||||||
ngx_pool_t *pool, ngx_str_t *err);
|
ngx_pool_t *pool, ngx_str_t *err);
|
||||||
|
ngx_uint_t ngx_regex_capture_count(ngx_regex_t *re);
|
||||||
ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s,
|
ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s,
|
||||||
int *matches, ngx_int_t size);
|
int *captures, ngx_int_t size);
|
||||||
|
|
||||||
#define ngx_regex_exec_n "pcre_exec()"
|
#define ngx_regex_exec_n "pcre_exec()"
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ee.events = event | flags;
|
ee.events = event | flags;
|
||||||
ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);
|
ee.data.u64 = (uintptr_t) c | ev->instance;
|
||||||
|
|
||||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
|
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
|
||||||
"epoll add event: fd:%d op:%d ev:%08XD",
|
"epoll add event: fd:%d op:%d ev:%08XD",
|
||||||
@ -282,7 +282,7 @@ static int ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
|
|||||||
if (e->active) {
|
if (e->active) {
|
||||||
op = EPOLL_CTL_MOD;
|
op = EPOLL_CTL_MOD;
|
||||||
ee.events = prev | flags;
|
ee.events = prev | flags;
|
||||||
ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);
|
ee.data.u64 = (uintptr_t) c | ev->instance;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
op = EPOLL_CTL_DEL;
|
op = EPOLL_CTL_DEL;
|
||||||
@ -311,7 +311,7 @@ static int ngx_epoll_add_connection(ngx_connection_t *c)
|
|||||||
struct epoll_event ee;
|
struct epoll_event ee;
|
||||||
|
|
||||||
ee.events = EPOLLIN|EPOLLOUT|EPOLLET;
|
ee.events = EPOLLIN|EPOLLOUT|EPOLLET;
|
||||||
ee.data.ptr = (void *) ((uintptr_t) c | c->read->instance);
|
ee.data.u64 = (uintptr_t) c | c->read->instance;
|
||||||
|
|
||||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
"epoll add connection: fd:%d ev:%08XD", c->fd, ee.events);
|
"epoll add connection: fd:%d ev:%08XD", c->fd, ee.events);
|
||||||
@ -351,7 +351,7 @@ static int ngx_epoll_del_connection(ngx_connection_t *c, u_int flags)
|
|||||||
|
|
||||||
op = EPOLL_CTL_DEL;
|
op = EPOLL_CTL_DEL;
|
||||||
ee.events = 0;
|
ee.events = 0;
|
||||||
ee.data.ptr = NULL;
|
ee.data.u64 = 0;
|
||||||
|
|
||||||
if (epoll_ctl(ep, op, c->fd, &ee) == -1) {
|
if (epoll_ctl(ep, op, c->fd, &ee) == -1) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
||||||
|
@ -318,6 +318,7 @@ static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle)
|
|||||||
rev = cycle->read_events;
|
rev = cycle->read_events;
|
||||||
for (i = 0; i < cycle->connection_n; i++) {
|
for (i = 0; i < cycle->connection_n; i++) {
|
||||||
rev[i].closed = 1;
|
rev[i].closed = 1;
|
||||||
|
rev[i].instance = 1;
|
||||||
#if (NGX_THREADS)
|
#if (NGX_THREADS)
|
||||||
rev[i].lock = &c[i].lock;
|
rev[i].lock = &c[i].lock;
|
||||||
rev[i].own_lock = &c[i].lock;
|
rev[i].own_lock = &c[i].lock;
|
||||||
@ -361,6 +362,7 @@ static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
ngx_memzero(c, sizeof(ngx_connection_t));
|
ngx_memzero(c, sizeof(ngx_connection_t));
|
||||||
ngx_memzero(rev, sizeof(ngx_event_t));
|
ngx_memzero(rev, sizeof(ngx_event_t));
|
||||||
|
ngx_memzero(wev, sizeof(ngx_event_t));
|
||||||
|
|
||||||
c->fd = s[i].fd;
|
c->fd = s[i].fd;
|
||||||
c->listening = &s[i];
|
c->listening = &s[i];
|
||||||
|
@ -144,6 +144,9 @@ static ngx_str_t ngx_http_fastcgi_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_str_t ngx_http_fastcgi_uri = ngx_string("/");
|
||||||
|
|
||||||
|
|
||||||
static ngx_http_header_t ngx_http_fastcgi_headers_in[] = {
|
static ngx_http_header_t ngx_http_fastcgi_headers_in[] = {
|
||||||
{ ngx_string("Status"), offsetof(ngx_http_fastcgi_headers_in_t, status) },
|
{ ngx_string("Status"), offsetof(ngx_http_fastcgi_headers_in_t, status) },
|
||||||
|
|
||||||
@ -474,8 +477,8 @@ static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flcf->params & NGX_HTTP_FASTCGI_REQUEST_URI) {
|
if (flcf->params & NGX_HTTP_FASTCGI_REQUEST_URI) {
|
||||||
len += 1 + ((r->uri.len > 127) ? 4 : 1)
|
len += 1 + ((r->unparsed_uri.len > 127) ? 4 : 1)
|
||||||
+ sizeof("REQUEST_URI") - 1 + r->uri.len;
|
+ sizeof("REQUEST_URI") - 1 + r->unparsed_uri.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flcf->params & NGX_HTTP_FASTCGI_SCRIPT_NAME) {
|
if (flcf->params & NGX_HTTP_FASTCGI_SCRIPT_NAME) {
|
||||||
@ -734,7 +737,7 @@ static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
if (flcf->params & NGX_HTTP_FASTCGI_REQUEST_URI) {
|
if (flcf->params & NGX_HTTP_FASTCGI_REQUEST_URI) {
|
||||||
*b->last++ = sizeof("REQUEST_URI") - 1;
|
*b->last++ = sizeof("REQUEST_URI") - 1;
|
||||||
|
|
||||||
len = r->uri.len;
|
len = r->unparsed_uri.len;
|
||||||
if (len > 127) {
|
if (len > 127) {
|
||||||
*b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80);
|
*b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80);
|
||||||
*b->last++ = (u_char) ((len >> 16) & 0xff);
|
*b->last++ = (u_char) ((len >> 16) & 0xff);
|
||||||
@ -746,7 +749,7 @@ static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
b->last = ngx_cpymem(b->last, "REQUEST_URI", sizeof("REQUEST_URI") - 1);
|
b->last = ngx_cpymem(b->last, "REQUEST_URI", sizeof("REQUEST_URI") - 1);
|
||||||
b->last = ngx_cpymem(b->last, r->uri.data, len);
|
b->last = ngx_cpymem(b->last, r->unparsed_uri.data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1718,7 +1721,6 @@ static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
unix_upstream.name = value[1];
|
unix_upstream.name = value[1];
|
||||||
unix_upstream.url = value[1];
|
unix_upstream.url = value[1];
|
||||||
|
|
||||||
|
|
||||||
if (!(lcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream))) {
|
if (!(lcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream))) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
@ -1744,9 +1746,10 @@ static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
|
|
||||||
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
||||||
|
|
||||||
lcf->location = &clcf->name;
|
|
||||||
clcf->handler = ngx_http_fastcgi_handler;
|
clcf->handler = ngx_http_fastcgi_handler;
|
||||||
|
|
||||||
|
lcf->location = clcf->regex ? &ngx_http_fastcgi_uri: &clcf->name;
|
||||||
|
|
||||||
if (clcf->name.data[clcf->name.len - 1] == '/') {
|
if (clcf->name.data[clcf->name.len - 1] == '/') {
|
||||||
clcf->auto_redirect = 1;
|
clcf->auto_redirect = 1;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ngx_regex_t *regex;
|
ngx_regex_t *regex;
|
||||||
ngx_uint_t msize;
|
ngx_uint_t ncaptures;
|
||||||
|
|
||||||
ngx_array_t ops;
|
ngx_array_t ops;
|
||||||
ngx_uint_t size;
|
ngx_uint_t size;
|
||||||
@ -113,7 +113,7 @@ ngx_module_t ngx_http_rewrite_module = {
|
|||||||
|
|
||||||
static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
|
static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
int *matches;
|
int *captures;
|
||||||
u_char *p;
|
u_char *p;
|
||||||
size_t len;
|
size_t len;
|
||||||
uintptr_t data;
|
uintptr_t data;
|
||||||
@ -132,18 +132,20 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
|
|||||||
rule = scf->rules.elts;
|
rule = scf->rules.elts;
|
||||||
for (i = 0; i < scf->rules.nelts; i++) {
|
for (i = 0; i < scf->rules.nelts; i++) {
|
||||||
|
|
||||||
if (rule[i].msize) {
|
if (rule[i].ncaptures) {
|
||||||
if (!(matches = ngx_palloc(r->pool, rule[i].msize * sizeof(int)))) {
|
captures = ngx_palloc(r->pool, rule[i].ncaptures * sizeof(int));
|
||||||
|
if (captures == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
matches = NULL;
|
captures = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ngx_regex_exec(rule[i].regex, &r->uri, matches, rule[i].msize);
|
rc = ngx_regex_exec(rule[i].regex, &r->uri,
|
||||||
|
captures, rule[i].ncaptures);
|
||||||
|
|
||||||
if (rc == NGX_DECLINED) {
|
if (rc == NGX_REGEX_NO_MATCHED) {
|
||||||
if (scf->log) {
|
if (scf->log) {
|
||||||
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
|
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
|
||||||
"\"%V\" does not match \"%V\"",
|
"\"%V\" does not match \"%V\"",
|
||||||
@ -174,7 +176,7 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
|
|||||||
uri.len = rule[i].size;
|
uri.len = rule[i].size;
|
||||||
|
|
||||||
for (n = 1; n < (ngx_uint_t) rc; n++) {
|
for (n = 1; n < (ngx_uint_t) rc; n++) {
|
||||||
uri.len += matches[2 * n + 1] - matches[2 * n];
|
uri.len += captures[2 * n + 1] - captures[2 * n];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(uri.data = ngx_palloc(r->pool, uri.len))) {
|
if (!(uri.data = ngx_palloc(r->pool, uri.len))) {
|
||||||
@ -198,11 +200,13 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
|
|||||||
|
|
||||||
} else { /* NGX_HTTP_REWRITE_COPY_MATCH */
|
} else { /* NGX_HTTP_REWRITE_COPY_MATCH */
|
||||||
m = 2 * op[n].data;
|
m = 2 * op[n].data;
|
||||||
p = ngx_cpymem(p, &r->uri.data[matches[m]],
|
p = ngx_cpymem(p, &r->uri.data[captures[m]],
|
||||||
matches[m + 1] - matches[m]);
|
captures[m + 1] - captures[m]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uri.len = p - uri.data;
|
||||||
|
|
||||||
if (scf->log) {
|
if (scf->log) {
|
||||||
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
|
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
|
||||||
"rewritten uri: \"%V\"", &uri);
|
"rewritten uri: \"%V\"", &uri);
|
||||||
@ -309,7 +313,7 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
u_char *data, *p;
|
u_char *data, *p;
|
||||||
size_t len;
|
size_t len;
|
||||||
ngx_str_t *value, err;
|
ngx_str_t *value, err;
|
||||||
ngx_uint_t i;
|
ngx_uint_t i, n;
|
||||||
ngx_http_rewrite_op_t *op;
|
ngx_http_rewrite_op_t *op;
|
||||||
ngx_http_rewrite_rule_t *rule;
|
ngx_http_rewrite_rule_t *rule;
|
||||||
u_char errstr[NGX_MAX_CONF_ERRSTR];
|
u_char errstr[NGX_MAX_CONF_ERRSTR];
|
||||||
@ -321,7 +325,7 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
ngx_init_array(rule->ops, cf->pool, 5, sizeof(ngx_http_rewrite_op_t),
|
ngx_init_array(rule->ops, cf->pool, 5, sizeof(ngx_http_rewrite_op_t),
|
||||||
NGX_CONF_ERROR);
|
NGX_CONF_ERROR);
|
||||||
|
|
||||||
rule->msize = 0;
|
rule->ncaptures = 0;
|
||||||
rule->size = 0;
|
rule->size = 0;
|
||||||
rule->status = 0;
|
rule->status = 0;
|
||||||
rule->last = 0;
|
rule->last = 0;
|
||||||
@ -371,8 +375,8 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
op->op = NGX_HTTP_REWRITE_COPY_MATCH;
|
op->op = NGX_HTTP_REWRITE_COPY_MATCH;
|
||||||
op->data = value[2].data[++i] - '0';
|
op->data = value[2].data[++i] - '0';
|
||||||
|
|
||||||
if (rule->msize < op->data) {
|
if (rule->ncaptures < op->data) {
|
||||||
rule->msize = op->data;
|
rule->ncaptures = op->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
@ -414,9 +418,22 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rule->msize) {
|
n = ngx_regex_capture_count(rule->regex);
|
||||||
rule->msize++;
|
|
||||||
rule->msize *= 3;
|
if (rule->ncaptures > n) {
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
"pattern \"%V\" has less captures "
|
||||||
|
"than referrenced in substitution \"%V\"",
|
||||||
|
&value[1], &value[2]);
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rule->ncaptures < n) {
|
||||||
|
rule->ncaptures = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rule->ncaptures) {
|
||||||
|
rule->ncaptures = (rule->ncaptures + 1) * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cf->args->nelts > 3) {
|
if (cf->args->nelts > 3) {
|
||||||
|
@ -1351,6 +1351,7 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
lcf->upstream->port_text = inet_upstream.port_text;
|
lcf->upstream->port_text = inet_upstream.port_text;
|
||||||
lcf->upstream->uri = inet_upstream.uri;
|
lcf->upstream->uri = inet_upstream.uri;
|
||||||
lcf->upstream->uri_separator = "";
|
lcf->upstream->uri_separator = "";
|
||||||
|
lcf->upstream->default_port = inet_upstream.default_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
||||||
|
@ -678,7 +678,7 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
|
|||||||
|
|
||||||
n = ngx_regex_exec(clcfp[i]->regex, &r->uri, NULL, 0);
|
n = ngx_regex_exec(clcfp[i]->regex, &r->uri, NULL, 0);
|
||||||
|
|
||||||
if (n == NGX_DECLINED) {
|
if (n == NGX_REGEX_NO_MATCHED) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1034,7 +1034,7 @@ static void ngx_http_upstream_finalize_request(ngx_http_request_t *r,
|
|||||||
r->connection->log->handler = u->saved_handler;
|
r->connection->log->handler = u->saved_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u->pipe.temp_file->file.fd) {
|
if (u->pipe.temp_file) {
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
"http upstream temp fd: %d",
|
"http upstream temp fd: %d",
|
||||||
u->pipe.temp_file->file.fd);
|
u->pipe.temp_file->file.fd);
|
||||||
@ -1048,7 +1048,7 @@ static void ngx_http_upstream_finalize_request(ngx_http_request_t *r,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (u->pipe.temp_file->file.fd) {
|
if (u->pipe.temp_file) {
|
||||||
r->file.fd = u->pipe.temp_file->file.fd;
|
r->file.fd = u->pipe.temp_file->file.fd;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -58,6 +58,7 @@ ngx_int_t ngx_write_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size,
|
|||||||
msg.msg_namelen = 0;
|
msg.msg_namelen = 0;
|
||||||
msg.msg_iov = iov;
|
msg.msg_iov = iov;
|
||||||
msg.msg_iovlen = 1;
|
msg.msg_iovlen = 1;
|
||||||
|
msg.msg_flags = 0;
|
||||||
|
|
||||||
n = sendmsg(s, &msg, 0);
|
n = sendmsg(s, &msg, 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user