mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
nginx-0.3.10-RELEASE import
*) Change: the "valid_referers" directive and the "$invalid_referer" variable were moved to the new ngx_http_referer_module from the ngx_http_rewrite_module. *) Change: the "$apache_bytes_sent" variable name was changed to "$body_bytes_sent". *) Feature: the "$sent_http_..." variables. *) Feature: the "if" directive supports the "=" and "!=" operations. *) Feature: the "proxy_pass" directive supports the HTTPS protocol. *) Feature: the "proxy_set_body" directive. *) Feature: the "post_action" directive. *) Feature: the ngx_http_empty_gif_module. *) Feature: the "worker_cpu_affinity" directive for Linux. *) Bugfix: the "rewrite" directive did not unescape URI part in redirect, now it is unescaped except the %00-%25 and %7F-%FF characters. *) Bugfix: nginx could not be built by the icc 9.0 compiler. *) Bugfix: if the SSI was enabled for zero size static file, then the chunked response was encoded incorrectly.
This commit is contained in:
parent
2a7f83eced
commit
0e5dc5cff6
12
auto/cc/icc
12
auto/cc/icc
@ -106,7 +106,7 @@ CFLAGS="$CFLAGS -wd1419"
|
||||
|
||||
case "$NGX_ICC_VER" in
|
||||
9.*)
|
||||
# "cc" clobber ignored, warnings for Liunx's htons()
|
||||
# "cc" clobber ignored, warnings for Liunx's htonl()/htons()
|
||||
CFLAGS="$CFLAGS -wd1469"
|
||||
# explicit conversion of a 64-bit integral type to a smaller
|
||||
# integral type
|
||||
@ -114,19 +114,11 @@ case "$NGX_ICC_VER" in
|
||||
# conversion from pointer to same-sized integral type,
|
||||
# warning on offsetof()
|
||||
CFLAGS="$CFLAGS -wd1684"
|
||||
|
||||
# STUB
|
||||
# non-POD class type passed through ellipsis, Linux only ?
|
||||
CFLAGS="$CFLAGS -wd1595"
|
||||
;;
|
||||
|
||||
8.*)
|
||||
# "cc" clobber ignored, warnings for Liunx's htons()
|
||||
# "cc" clobber ignored, warnings for Liunx's htonl()/htons()
|
||||
CFLAGS="$CFLAGS -wd1469"
|
||||
|
||||
# STUB
|
||||
# non-POD class type passed through ellipsis, Linux only ?
|
||||
CFLAGS="$CFLAGS -wd1595"
|
||||
;;
|
||||
|
||||
*)
|
||||
|
@ -5,7 +5,7 @@
|
||||
echo $ngx_n "checking for C compiler ...$ngx_c"
|
||||
|
||||
|
||||
if [ $CC = cl ]; then
|
||||
if [ "$CC" = cl ]; then
|
||||
if `$NGX_WINE $CC -v 2>&1 \
|
||||
| grep '^Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13' \
|
||||
2>&1 >/dev/null`; then
|
||||
@ -19,12 +19,12 @@ if [ $CC = cl ]; then
|
||||
fi
|
||||
|
||||
else
|
||||
if [ $CC = wcl386 ]; then
|
||||
if [ "$CC" = wcl386 ]; then
|
||||
NGX_CC_NAME=owc
|
||||
echo " Open Watcom C compiler"
|
||||
|
||||
else
|
||||
if [ $CC = bcc32 ]; then
|
||||
if [ "$CC" = bcc32 ]; then
|
||||
NGX_CC_NAME=bcc
|
||||
echo " Borland C++ compiler"
|
||||
|
||||
|
@ -20,7 +20,10 @@ int main() {
|
||||
|
||||
END
|
||||
|
||||
eval "${CC} -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1"
|
||||
ngx_test="$CC $CC_TEST_FLAGS $CC_WARN $CC_AUX_FLAGS \
|
||||
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
|
||||
|
||||
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
|
||||
|
||||
if [ -x $NGX_AUTOTEST ]; then
|
||||
if $NGX_AUTOTEST 2>&1 > /dev/null; then
|
||||
|
@ -8,6 +8,7 @@ if [ $OPENSSL != NONE ]; then
|
||||
case "$CC" in
|
||||
*)
|
||||
have=NGX_OPENSSL . auto/have
|
||||
have=NGX_SSL . auto/have
|
||||
LINK_DEPS="$LINK_DEPS $OPENSSL/libssl.a $OPENSSL/libcrypto.a"
|
||||
CORE_LIBS="$CORE_LIBS $OPENSSL/libssl.a $OPENSSL/libcrypto.a"
|
||||
;;
|
||||
@ -34,6 +35,7 @@ else
|
||||
. auto/feature
|
||||
|
||||
if [ $ngx_found = yes ]; then
|
||||
have=NGX_SSL . auto/have
|
||||
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
|
||||
OPENSSL=YES
|
||||
|
||||
|
14
auto/modules
14
auto/modules
@ -65,6 +65,9 @@ fi
|
||||
# ngx_http_autoindex_module
|
||||
# ngx_http_index_module
|
||||
#
|
||||
# ngx_http_access_module
|
||||
# ngx_http_realip_module
|
||||
#
|
||||
#
|
||||
# the filter order is important
|
||||
# ngx_http_write_filter
|
||||
@ -157,6 +160,11 @@ if [ $HTTP_GEO = YES ]; then
|
||||
HTTP_SRCS="$HTTP_SRCS $HTTP_GEO_SRCS"
|
||||
fi
|
||||
|
||||
if [ $HTTP_REFERER = YES ]; then
|
||||
HTTP_MODULES="$HTTP_MODULES $HTTP_REFERER_MODULE"
|
||||
HTTP_SRCS="$HTTP_SRCS $HTTP_REFERER_SRCS"
|
||||
fi
|
||||
|
||||
if [ $HTTP_REWRITE = YES -a $USE_PCRE != DISABLED ]; then
|
||||
have=NGX_HTTP_REWRITE . auto/have
|
||||
USE_PCRE=YES
|
||||
@ -186,6 +194,11 @@ if [ $HTTP_FASTCGI = YES ]; then
|
||||
HTTP_SRCS="$HTTP_SRCS $HTTP_FASTCGI_SRCS"
|
||||
fi
|
||||
|
||||
if [ $HTTP_EMPTY_GIF = YES ]; then
|
||||
HTTP_MODULES="$HTTP_MODULES $HTTP_EMPTY_GIF_MODULE"
|
||||
HTTP_SRCS="$HTTP_SRCS $HTTP_EMPTY_GIF_SRCS"
|
||||
fi
|
||||
|
||||
# STUB
|
||||
#USE_MD5=YES
|
||||
#HTTP_SRCS="$HTTP_SRCS $HTPP_CACHE_SRCS"
|
||||
@ -243,6 +256,7 @@ fi
|
||||
if [ $HTTP = YES ]; then
|
||||
modules="$modules $HTTP_MODULES $HTTP_FILTER_MODULES \
|
||||
$HTTP_HEADERS_FILTER_MODULE \
|
||||
$HTTP_AUX_FILTER_MODULES \
|
||||
$HTTP_COPY_FILTER_MODULE \
|
||||
$HTTP_RANGE_BODY_FILTER_MODULE \
|
||||
$HTTP_NOT_MODIFIED_FILTER_MODULE"
|
||||
|
@ -57,9 +57,11 @@ HTTP_USERID=YES
|
||||
HTTP_AUTOINDEX=YES
|
||||
HTTP_STATUS=NO
|
||||
HTTP_GEO=YES
|
||||
HTTP_REFERER=YES
|
||||
HTTP_REWRITE=YES
|
||||
HTTP_PROXY=YES
|
||||
HTTP_FASTCGI=YES
|
||||
HTTP_EMPTY_GIF=YES
|
||||
|
||||
# STUB
|
||||
HTTP_STUB_STATUS=NO
|
||||
@ -136,9 +138,11 @@ do
|
||||
--without-http_autoindex_module) HTTP_AUTOINDEX=NO ;;
|
||||
--without-http_status_module) HTTP_STATUS=NO ;;
|
||||
--without-http_geo_module) HTTP_GEO=NO ;;
|
||||
--without-http_referer) HTTP_REFERER=NO ;;
|
||||
--without-http_rewrite_module) HTTP_REWRITE=NO ;;
|
||||
--without-http_proxy_module) HTTP_PROXY=NO ;;
|
||||
--without-http_fastcgi_module) HTTP_FASTCGI=NO ;;
|
||||
--without-http_epmty_gif_module) HTTP_EMPTY_GIF=NO ;;
|
||||
|
||||
# STUB
|
||||
--with-http_stub_status_module) HTTP_STUB_STATUS=YES ;;
|
||||
|
@ -100,3 +100,15 @@ ngx_feature_incs="#include <sys/prctl.h>"
|
||||
ngx_feature_libs=
|
||||
ngx_feature_test="if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) return 1"
|
||||
. auto/feature
|
||||
|
||||
|
||||
# sched_setaffinity()
|
||||
|
||||
ngx_feature="sched_setaffinity()"
|
||||
ngx_feature_name="NGX_HAVE_SCHED_SETAFFINITY"
|
||||
ngx_feature_run=no
|
||||
ngx_feature_incs="#include <sched.h>"
|
||||
ngx_feature_libs=
|
||||
ngx_feature_test="long mask = 0;
|
||||
sched_setaffinity(0, 32, &mask)"
|
||||
. auto/feature
|
||||
|
@ -334,6 +334,10 @@ HTTP_GEO_MODULE=ngx_http_geo_module
|
||||
HTTP_GEO_SRCS=src/http/modules/ngx_http_geo_module.c
|
||||
|
||||
|
||||
HTTP_REFERER_MODULE=ngx_http_referer_module
|
||||
HTTP_REFERER_SRCS=src/http/modules/ngx_http_referer_module.c
|
||||
|
||||
|
||||
HTTP_REWRITE_MODULE=ngx_http_rewrite_module
|
||||
HTTP_REWRITE_SRCS=src/http/modules/ngx_http_rewrite_module.c
|
||||
|
||||
@ -351,6 +355,10 @@ HTTP_FASTCGI_MODULE=ngx_http_fastcgi_module
|
||||
HTTP_FASTCGI_SRCS=src/http/modules/ngx_http_fastcgi_module.c
|
||||
|
||||
|
||||
HTTP_EMPTY_GIF_MODULE=ngx_http_empty_gif_module
|
||||
HTTP_EMPTY_GIF_SRCS=src/http/modules/ngx_http_empty_gif_module.c
|
||||
|
||||
|
||||
IMAP_INCS="src/imap"
|
||||
|
||||
IMAP_DEPS="src/imap/ngx_imap.h"
|
||||
|
@ -31,7 +31,9 @@ int main() {
|
||||
END
|
||||
|
||||
|
||||
ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
|
||||
ngx_test="$CC $CC_TEST_FLAGS $CC_WARN $CC_AUX_FLAGS \
|
||||
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
|
||||
|
||||
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
|
||||
|
||||
|
||||
|
@ -3,6 +3,9 @@
|
||||
worker_processes 1;
|
||||
|
||||
#error_log logs/error.log;
|
||||
#error_log logs/error.log notice;
|
||||
#error_log logs/error.log info;
|
||||
|
||||
#pid logs/nginx.pid;
|
||||
|
||||
|
||||
@ -15,7 +18,14 @@ http {
|
||||
include conf/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
#log_format main '$remote_addr - $remote_user [$time_gmt] $status '
|
||||
# '"$request" $body_bytes_sent "$http_referer" '
|
||||
# '"$http_user_agent" "http_x_forwarded_for"';
|
||||
|
||||
#access_log logs/access.log main;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
#tcp_nodelay on;
|
||||
|
||||
#keepalive_timeout 0;
|
||||
@ -24,10 +34,11 @@ http {
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
#charset koi8-r;
|
||||
|
||||
#access_log logs/access.log;
|
||||
#access_log logs/host.access.log main;
|
||||
|
||||
location / {
|
||||
root html;
|
||||
@ -40,10 +51,60 @@ http {
|
||||
# proxy_pass http://127.0.0.1;
|
||||
#}
|
||||
|
||||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
||||
#
|
||||
#location ~ \.php$ {
|
||||
# fastcgi_pass 127.0.0.1:9000;
|
||||
# fastcgi_index index.php;
|
||||
# fastcgi_param PATH_TRANSLATED /scripts$fastcgi_script_name;
|
||||
# include conf/fastcgi_params;
|
||||
#}
|
||||
|
||||
# deny access to .htaccess files
|
||||
#
|
||||
#location ~ /\.ht {
|
||||
# deny all;
|
||||
#}
|
||||
|
||||
#error_page 404 /404.html;
|
||||
#error_page 500 502 503 504 /50x.html;
|
||||
}
|
||||
|
||||
|
||||
# another virtual host using mix of IP-, name-, and port-based configuration
|
||||
#
|
||||
#server {
|
||||
# listen 8000;
|
||||
# listen somename:8080;
|
||||
# server_name somename alias another.alias;
|
||||
|
||||
# location / {
|
||||
# root html;
|
||||
# index index.html index.htm;
|
||||
# }
|
||||
#}
|
||||
|
||||
|
||||
# HTTPS server
|
||||
#
|
||||
#server {
|
||||
# listen 443;
|
||||
# server_name localhost;
|
||||
|
||||
# ssl on;
|
||||
# ssl_certificate cert.pem;
|
||||
# ssl_certificate_key cert.key;
|
||||
|
||||
# ssl_session_timeout 5m;
|
||||
|
||||
# ssl_protocols SSLv2 SSLv3 TLSv1;
|
||||
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
|
||||
# ssl_prefer_server_ciphers on;
|
||||
|
||||
# location / {
|
||||
# root html;
|
||||
# index index.html index.htm;
|
||||
# }
|
||||
#}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,125 @@
|
||||
<title lang="en">nginx changelog</title>
|
||||
|
||||
|
||||
<changes ver="0.3.10" date="15.11.2005">
|
||||
|
||||
<change type="change">
|
||||
<para lang="ru">
|
||||
ÄÉÒÅËÔÉ×Á valid_referers É ÐÅÒÅÍÅÎÎÁÑ $invalid_referer ÐÅÒÅÎÅÓÅÎÙ
|
||||
ÉÚ ÍÏÄÕÌÑ ngx_http_rewrite_module × ÎÏ×ÙÊ ÍÏÄÕÌØ ngx_http_referer_module.
|
||||
</para>
|
||||
<para lang="en">
|
||||
the "valid_referers" directive and the "$invalid_referer" variable
|
||||
was moved to the new ngx_http_referer_module from the ngx_http_rewrite_module.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="change">
|
||||
<para lang="ru">
|
||||
ÉÍÑ ÐÅÒÅÍÅÎÎÏÊ "$apache_bytes_sent" ÉÚÍÅÎÅÎÏ ÎÁ "$body_bytes_sent".
|
||||
</para>
|
||||
<para lang="en">
|
||||
the "$apache_bytes_sent" variable name was changed to "$body_bytes_sent".
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="feature">
|
||||
<para lang="ru">
|
||||
ÐÅÒÅÍÅÎÎÙÅ "$sent_http_...".
|
||||
</para>
|
||||
<para lang="en">
|
||||
the "$sent_http_..." variables.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="feature">
|
||||
<para lang="ru">
|
||||
ÄÉÒÅËÔÉ×Á if ÐÏÄÄÅÒÖÉ×ÁÅÔ ÏÐÅÒÁÃÉÉ "=" É "!=".
|
||||
</para>
|
||||
<para lang="en">
|
||||
the "if" directive supports the "=" and "!=" operations.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="feature">
|
||||
<para lang="ru">
|
||||
ÄÉÒÅËÔÉ×Á proxy_pass ÐÏÄÄÅÒÖÉ×ÁÅÔ ÐÒÏÔÏËÏÌ HTTPS.
|
||||
</para>
|
||||
<para lang="en">
|
||||
the "proxy_set_body" directive supports the HTTPS protocol.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="feature">
|
||||
<para lang="ru">
|
||||
ÄÉÒÅËÔÉ×Á proxy_set_body.
|
||||
</para>
|
||||
<para lang="en">
|
||||
the "proxy_set_body" directive.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="feature">
|
||||
<para lang="ru">
|
||||
ÄÉÒÅËÔÉ×Á post_action.
|
||||
</para>
|
||||
<para lang="en">
|
||||
the "post_action" directive.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="feature">
|
||||
<para lang="ru">
|
||||
ÍÏÄÕÌØ ngx_http_empty_gif_module.
|
||||
</para>
|
||||
<para lang="en">
|
||||
the ngx_http_empty_gif_module.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="feature">
|
||||
<para lang="ru">
|
||||
ÄÉÒÅËÔÉ×Á worker_cpu_affinity ÄÌÑ Linux.
|
||||
</para>
|
||||
<para lang="en">
|
||||
the "worker_cpu_affinity" directive for Linux.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="bugfix">
|
||||
<para lang="ru">
|
||||
ÄÉÒÅËÔÉ×Á rewrite ÎÅ ÒÁÓËÏÄÉÒÏ×ÁÌÁ ÓÉÍ×ÏÌÙ × ÒÅÄÉÒÅËÔÁÈ × URI,
|
||||
ÔÅÐÅÒØ ÓÉÍ×ÏÌÙ ÒÁÓËÏÄÉÒÕÀÔÓÑ, ËÒÏÍÅ ÓÉÍ×ÏÌÏ× %00-%25 É %7F-%FF.
|
||||
</para>
|
||||
<para lang="en">
|
||||
the "rewrite" directive did not unescape URI part in redirect,
|
||||
now it is unescaped except the %00-%25 and %7F-%FF characters.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="bugfix">
|
||||
<para lang="ru">
|
||||
nginx ÎÅ ÓÏÂÉÒÁÌÓÑ ËÏÍÐÉÌÑÔÏÒÏÍ icc 9.0.
|
||||
</para>
|
||||
<para lang="en">
|
||||
nginx could not be built by the icc 9.0 compiler.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="bugfix">
|
||||
<para lang="ru">
|
||||
ÅÓÌÉ ÄÌÑ ÓÔÁÔÉÞÅÓËÏÇÏ ÆÁÊÌÁ ÎÕÌÅ×ÏÇÏ ÒÁÚÍÅÒÁ ÂÙÌ ÒÁÚÒÅۣΠSSI,
|
||||
ÔÏ ÏÔ×ÅÔ ÐÅÒÅÄÁ×ÁÌÓÑ ÎÅ×ÅÒÎÏ ÐÒÉ ËÏÄÉÒÏ×ÁÎÉÉ chunk'ÁÍÉ.
|
||||
</para>
|
||||
<para lang="en">
|
||||
if the SSI was enabled for zero size static file, then the chunked
|
||||
response was encoded incorrectly.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
</changes>
|
||||
|
||||
|
||||
<changes ver="0.3.9" date="10.11.2005">
|
||||
|
||||
<change type="bugfix">
|
||||
@ -85,7 +204,6 @@ the "add_header" directive.
|
||||
</para>
|
||||
<para lang="en">
|
||||
the ngx_http_realip_module.
|
||||
directives.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
|
119
src/core/nginx.c
119
src/core/nginx.c
@ -17,6 +17,8 @@ static void *ngx_core_module_create_conf(ngx_cycle_t *cycle);
|
||||
static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf);
|
||||
static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
||||
static char *ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
||||
static char *ngx_set_cpu_affinity(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
void *conf);
|
||||
|
||||
|
||||
static ngx_conf_enum_t ngx_debug_points[] = {
|
||||
@ -84,6 +86,13 @@ static ngx_command_t ngx_core_commands[] = {
|
||||
0,
|
||||
NULL },
|
||||
|
||||
{ ngx_string("worker_cpu_affinity"),
|
||||
NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_1MORE,
|
||||
ngx_set_cpu_affinity,
|
||||
0,
|
||||
0,
|
||||
NULL },
|
||||
|
||||
{ ngx_string("worker_rlimit_nofile"),
|
||||
NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_num_slot,
|
||||
@ -537,6 +546,8 @@ ngx_core_module_create_conf(ngx_cycle_t *cycle)
|
||||
* ccf->pid = NULL;
|
||||
* ccf->oldpid = NULL;
|
||||
* ccf->priority = 0;
|
||||
* ccf->cpu_affinity_n = 0;
|
||||
* ccf->cpu_affinity = NULL;
|
||||
*/
|
||||
|
||||
ccf->daemon = NGX_CONF_UNSET;
|
||||
@ -578,10 +589,26 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||
ngx_conf_init_value(ccf->worker_processes, 1);
|
||||
ngx_conf_init_value(ccf->debug_points, 0);
|
||||
|
||||
#if (NGX_HAVE_SCHED_SETAFFINITY)
|
||||
|
||||
if (ccf->cpu_affinity_n
|
||||
&& ccf->cpu_affinity_n != 1
|
||||
&& ccf->cpu_affinity_n != (ngx_uint_t) ccf->worker_processes)
|
||||
{
|
||||
ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
|
||||
"number of the \"worker_processes\" is not equal to "
|
||||
"the number of the \"worker_cpu_affinity\" mask, "
|
||||
"using last mask for remaining worker processes");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if (NGX_THREADS)
|
||||
|
||||
ngx_conf_init_value(ccf->worker_threads, 0);
|
||||
ngx_threads_n = ccf->worker_threads;
|
||||
ngx_conf_init_size_value(ccf->thread_stack_size, 2 * 1024 * 1024);
|
||||
|
||||
#endif
|
||||
|
||||
#if !(NGX_WIN32)
|
||||
@ -732,3 +759,95 @@ ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
ngx_set_cpu_affinity(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
#if (NGX_HAVE_SCHED_SETAFFINITY)
|
||||
ngx_core_conf_t *ccf = conf;
|
||||
|
||||
u_char ch;
|
||||
u_long *mask;
|
||||
ngx_str_t *value;
|
||||
ngx_uint_t i, n;
|
||||
|
||||
if (ccf->cpu_affinity) {
|
||||
return "is duplicate";
|
||||
}
|
||||
|
||||
mask = ngx_palloc(cf->pool, (cf->args->nelts - 1) * sizeof(long));
|
||||
if (mask == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ccf->cpu_affinity_n = cf->args->nelts - 1;
|
||||
ccf->cpu_affinity = mask;
|
||||
|
||||
value = cf->args->elts;
|
||||
|
||||
for (n = 1; n < cf->args->nelts; n++) {
|
||||
|
||||
if (value[n].len > 32) {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"\"worker_cpu_affinity\" supports up to 32 CPU only");
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
mask[n - 1] = 0;
|
||||
|
||||
for (i = 0; i < value[n].len; i++) {
|
||||
|
||||
ch = value[n].data[i];
|
||||
|
||||
if (ch == ' ') {
|
||||
continue;
|
||||
}
|
||||
|
||||
mask[n - 1] <<= 1;
|
||||
|
||||
if (ch == '0') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '1') {
|
||||
mask[n - 1] |= 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"invalid character \"%c\" in \"worker_cpu_affinity\"",
|
||||
ch);
|
||||
return NGX_CONF_ERROR ;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
||||
"\"worker_cpu_affinity\" is not supported "
|
||||
"on this platform, ignored");
|
||||
#endif
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
|
||||
u_long
|
||||
ngx_get_cpu_affinity(ngx_uint_t n)
|
||||
{
|
||||
ngx_core_conf_t *ccf;
|
||||
|
||||
ccf = (ngx_core_conf_t *) ngx_get_conf(ngx_cycle->conf_ctx,
|
||||
ngx_core_module);
|
||||
|
||||
if (ccf->cpu_affinity == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ccf->cpu_affinity_n > n) {
|
||||
return ccf->cpu_affinity[n];
|
||||
}
|
||||
|
||||
return ccf->cpu_affinity[ccf->cpu_affinity_n - 1];
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define _NGINX_H_INCLUDED_
|
||||
|
||||
|
||||
#define NGINX_VER "nginx/0.3.9"
|
||||
#define NGINX_VER "nginx/0.3.10"
|
||||
|
||||
#define NGINX_VAR "NGINX"
|
||||
#define NGX_OLDPID_EXT ".oldbin"
|
||||
|
@ -102,6 +102,7 @@ struct ngx_connection_s {
|
||||
|
||||
ngx_recv_pt recv;
|
||||
ngx_send_pt send;
|
||||
ngx_recv_chain_pt recv_chain;
|
||||
ngx_send_chain_pt send_chain;
|
||||
|
||||
ngx_listening_t *listening;
|
||||
@ -120,7 +121,7 @@ struct ngx_connection_s {
|
||||
socklen_t socklen;
|
||||
ngx_str_t addr_text;
|
||||
|
||||
#if (NGX_OPENSSL)
|
||||
#if (NGX_SSL)
|
||||
ngx_ssl_connection_t *ssl;
|
||||
#endif
|
||||
|
||||
|
@ -64,6 +64,9 @@ typedef struct {
|
||||
|
||||
int priority;
|
||||
|
||||
ngx_uint_t cpu_affinity_n;
|
||||
u_long *cpu_affinity;
|
||||
|
||||
char *username;
|
||||
ngx_uid_t user;
|
||||
ngx_gid_t group;
|
||||
@ -91,6 +94,7 @@ ngx_int_t ngx_create_pidfile(ngx_cycle_t *cycle, ngx_cycle_t *old_cycle);
|
||||
void ngx_delete_pidfile(ngx_cycle_t *cycle);
|
||||
void ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user);
|
||||
ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv);
|
||||
u_long ngx_get_cpu_affinity(ngx_uint_t n);
|
||||
|
||||
|
||||
extern volatile ngx_cycle_t *ngx_cycle;
|
||||
|
@ -473,7 +473,8 @@ ngx_chain_writer(void *data, ngx_chain_t *in)
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
ctx->out = ngx_send_chain(ctx->connection, ctx->out, ctx->limit);
|
||||
ctx->out = ctx->connection->send_chain(ctx->connection, ctx->out,
|
||||
ctx->limit);
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->connection->log, 0,
|
||||
"chain writer out: %p", ctx->out);
|
||||
|
@ -928,3 +928,111 @@ ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type)
|
||||
|
||||
return (uintptr_t) dst;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ngx_unescape_uri(u_char **dst, u_char **src, size_t size)
|
||||
{
|
||||
u_char *d, *s, ch, c, decoded;
|
||||
enum {
|
||||
sw_usual = 0,
|
||||
sw_quoted,
|
||||
sw_quoted_second
|
||||
} state;
|
||||
|
||||
d = *dst;
|
||||
s = *src;
|
||||
|
||||
state = 0;
|
||||
decoded = 0;
|
||||
|
||||
while (size--) {
|
||||
|
||||
ch = *s++;
|
||||
|
||||
switch (state) {
|
||||
case sw_usual:
|
||||
if (ch == '?') {
|
||||
*d++ = ch;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (ch == '%') {
|
||||
state = sw_quoted;
|
||||
break;
|
||||
}
|
||||
|
||||
*d++ = ch;
|
||||
break;
|
||||
|
||||
case sw_quoted:
|
||||
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
decoded = (u_char) (ch - '0');
|
||||
state = sw_quoted_second;
|
||||
break;
|
||||
}
|
||||
|
||||
c = (u_char) (ch | 0x20);
|
||||
if (c >= 'a' && c <= 'f') {
|
||||
decoded = (u_char) (c - 'a' + 10);
|
||||
state = sw_quoted_second;
|
||||
break;
|
||||
}
|
||||
|
||||
/* skip the invalid quoted character */
|
||||
|
||||
s++;
|
||||
size--;
|
||||
|
||||
break;
|
||||
|
||||
case sw_quoted_second:
|
||||
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
ch = (u_char) ((decoded << 4) + ch - '0');
|
||||
|
||||
state = sw_usual;
|
||||
|
||||
if (ch > '%' && ch < 0x7f) {
|
||||
*d++ = ch;
|
||||
break;
|
||||
}
|
||||
|
||||
*d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
c = (u_char) (ch | 0x20);
|
||||
if (c >= 'a' && c <= 'f') {
|
||||
ch = (u_char) ((decoded << 4) + c - 'a' + 10);
|
||||
|
||||
if (ch == '?') {
|
||||
*d++ = ch;
|
||||
goto done;
|
||||
}
|
||||
|
||||
state = sw_usual;
|
||||
|
||||
if (ch > '%' && ch < 0x7f) {
|
||||
*d++ = ch;
|
||||
break;
|
||||
}
|
||||
|
||||
*d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* skip the invalid quoted character */
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
*dst = d;
|
||||
*src = s;
|
||||
}
|
||||
|
@ -141,6 +141,7 @@ u_char * ngx_utf_cpystrn(u_char *dst, u_char *src, size_t n);
|
||||
|
||||
uintptr_t ngx_escape_uri(u_char *dst, u_char *src, size_t size,
|
||||
ngx_uint_t type);
|
||||
void ngx_unescape_uri(u_char **dst, u_char **src, size_t size);
|
||||
|
||||
|
||||
#define ngx_qsort qsort
|
||||
|
@ -471,7 +471,7 @@ ngx_epoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags)
|
||||
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
"epoll: fd:%d ev:%04XD d:%p",
|
||||
c->fd, revents, event_list[i].data);
|
||||
c->fd, revents, event_list[i].data.ptr);
|
||||
|
||||
if (revents & (EPOLLERR|EPOLLHUP)) {
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
|
@ -142,6 +142,7 @@ ngx_event_accept(ngx_event_t *ev)
|
||||
|
||||
c->recv = ngx_recv;
|
||||
c->send = ngx_send;
|
||||
c->recv_chain = ngx_recv_chain;
|
||||
c->send_chain = ngx_send_chain;
|
||||
|
||||
c->log = log;
|
||||
|
@ -153,6 +153,7 @@ ngx_event_post_acceptex(ngx_listening_t *ls, ngx_uint_t n)
|
||||
|
||||
c->recv = ngx_recv;
|
||||
c->send = ngx_send;
|
||||
c->recv_chain = ngx_recv_chain;
|
||||
c->send_chain = ngx_send_chain;
|
||||
|
||||
c->unexpected_eof = 1;
|
||||
|
@ -173,6 +173,7 @@ ngx_event_connect_peer(ngx_peer_connection_t *pc)
|
||||
|
||||
c->recv = ngx_recv;
|
||||
c->send = ngx_send;
|
||||
c->recv_chain = ngx_recv_chain;
|
||||
c->send_chain = ngx_send_chain;
|
||||
|
||||
c->log_error = pc->log_error;
|
||||
|
@ -27,6 +27,10 @@ typedef struct {
|
||||
|
||||
ngx_uint_t max_fails;
|
||||
time_t fail_timeout;
|
||||
|
||||
#if (NGX_SSL)
|
||||
ngx_ssl_session_t *ssl_session;
|
||||
#endif
|
||||
} ngx_peer_t;
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@ static void ngx_ssl_handshake_handler(ngx_event_t *ev);
|
||||
static ngx_int_t ngx_ssl_handle_recv(ngx_connection_t *c, int n);
|
||||
static void ngx_ssl_write_handler(ngx_event_t *wev);
|
||||
static void ngx_ssl_read_handler(ngx_event_t *rev);
|
||||
static void ngx_ssl_shutdown_handler(ngx_event_t *ev);
|
||||
static void ngx_ssl_connection_error(ngx_connection_t *c, int sslerr,
|
||||
ngx_err_t err, char *text);
|
||||
static void *ngx_openssl_create_conf(ngx_cycle_t *cycle);
|
||||
@ -99,19 +100,20 @@ ngx_ssl_init(ngx_log_t *log)
|
||||
ngx_int_t
|
||||
ngx_ssl_create(ngx_ssl_t *ssl, ngx_uint_t protocols)
|
||||
{
|
||||
ssl->ctx = SSL_CTX_new(SSLv23_server_method());
|
||||
ssl->ctx = SSL_CTX_new(SSLv23_method());
|
||||
|
||||
if (ssl->ctx == NULL) {
|
||||
ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0, "SSL_CTX_new() failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* these options are needed on client side only:
|
||||
* SSL_OP_MICROSOFT_SESS_ID_BUG
|
||||
* SSL_OP_NETSCAPE_CHALLENGE_BUG
|
||||
* SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
|
||||
*/
|
||||
/* client side options */
|
||||
|
||||
SSL_CTX_set_options(ssl->ctx, SSL_OP_MICROSOFT_SESS_ID_BUG);
|
||||
SSL_CTX_set_options(ssl->ctx, SSL_OP_NETSCAPE_CHALLENGE_BUG);
|
||||
SSL_CTX_set_options(ssl->ctx, SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG);
|
||||
|
||||
/* server side options */
|
||||
|
||||
SSL_CTX_set_options(ssl->ctx, SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG);
|
||||
SSL_CTX_set_options(ssl->ctx, SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER);
|
||||
@ -224,7 +226,12 @@ ngx_ssl_create_connection(ngx_ssl_t *ssl, ngx_connection_t *c, ngx_uint_t flags)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (flags & NGX_SSL_CLIENT) {
|
||||
SSL_set_connect_state(sc->connection);
|
||||
|
||||
} else {
|
||||
SSL_set_accept_state(sc->connection);
|
||||
}
|
||||
|
||||
c->ssl = sc;
|
||||
|
||||
@ -232,6 +239,20 @@ ngx_ssl_create_connection(ngx_ssl_t *ssl, ngx_connection_t *c, ngx_uint_t flags)
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_ssl_set_session(ngx_connection_t *c, ngx_ssl_session_t *session)
|
||||
{
|
||||
if (session) {
|
||||
if (SSL_set_session(c->ssl->connection, session) == 0) {
|
||||
ngx_ssl_error(NGX_LOG_ALERT, c->log, 0, "SSL_set_session() failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_ssl_handshake(ngx_connection_t *c)
|
||||
{
|
||||
@ -300,6 +321,7 @@ ngx_ssl_handshake(ngx_connection_t *c)
|
||||
|
||||
c->recv = ngx_ssl_recv;
|
||||
c->send = ngx_ssl_write;
|
||||
c->recv_chain = ngx_ssl_recv_chain;
|
||||
c->send_chain = ngx_ssl_send_chain;
|
||||
|
||||
return NGX_OK;
|
||||
@ -338,7 +360,7 @@ ngx_ssl_handshake(ngx_connection_t *c)
|
||||
|
||||
if (sslerr == SSL_ERROR_ZERO_RETURN || ERR_peek_error() == 0) {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, err,
|
||||
"client closed connection in SSL handshake");
|
||||
"peer closed connection in SSL handshake");
|
||||
|
||||
return NGX_ERROR;
|
||||
}
|
||||
@ -357,7 +379,7 @@ ngx_ssl_handshake_handler(ngx_event_t *ev)
|
||||
c = ev->data;
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||
"ssl handshake handler: %d", ev->write);
|
||||
"SSL handshake handler: %d", ev->write);
|
||||
|
||||
if (ngx_ssl_handshake(c) == NGX_AGAIN) {
|
||||
return;
|
||||
@ -367,6 +389,41 @@ ngx_ssl_handshake_handler(ngx_event_t *ev)
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl)
|
||||
{
|
||||
ssize_t n, bytes;
|
||||
ngx_buf_t *b;
|
||||
|
||||
bytes = 0;
|
||||
|
||||
while (cl) {
|
||||
b = cl->buf;
|
||||
|
||||
n = ngx_ssl_recv(c, b->last, b->end - b->last);
|
||||
|
||||
if (n > 0) {
|
||||
b->last += n;
|
||||
bytes += n;
|
||||
|
||||
if (b->last == b->end) {
|
||||
cl = cl->next;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bytes) {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size)
|
||||
{
|
||||
@ -376,6 +433,10 @@ ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (c->ssl->last == NGX_DONE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bytes = 0;
|
||||
|
||||
/*
|
||||
@ -399,10 +460,13 @@ ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size)
|
||||
|
||||
if (bytes) {
|
||||
return bytes;
|
||||
|
||||
} else {
|
||||
return c->ssl->last;
|
||||
}
|
||||
|
||||
if (c->ssl->last == NGX_DONE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return c->ssl->last;
|
||||
}
|
||||
|
||||
size -= n;
|
||||
@ -454,7 +518,7 @@ ngx_ssl_handle_recv(ngx_connection_t *c, int n)
|
||||
if (sslerr == SSL_ERROR_WANT_WRITE) {
|
||||
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, 0,
|
||||
"client started SSL renegotiation");
|
||||
"peer started SSL renegotiation");
|
||||
|
||||
c->write->ready = 0;
|
||||
|
||||
@ -478,9 +542,9 @@ ngx_ssl_handle_recv(ngx_connection_t *c, int n)
|
||||
c->ssl->no_send_shutdown = 1;
|
||||
|
||||
if (sslerr == SSL_ERROR_ZERO_RETURN || ERR_peek_error() == 0) {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, err, "client closed connection");
|
||||
|
||||
return NGX_ERROR;
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||
"peer shutdown SSL cleanly");
|
||||
return NGX_DONE;
|
||||
}
|
||||
|
||||
ngx_ssl_connection_error(c, sslerr, err, "SSL_read() failed");
|
||||
@ -516,15 +580,20 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
ssize_t send, size;
|
||||
ngx_buf_t *buf;
|
||||
|
||||
buf = c->ssl->buf;
|
||||
|
||||
if (in && in->next == NULL && !c->buffered && !c->ssl->buffer) {
|
||||
if (!c->ssl->buffer || (in && in->next == NULL && !c->buffered)) {
|
||||
|
||||
/*
|
||||
* we avoid a buffer copy if the incoming buf is a single,
|
||||
* our buffer is empty, and we do not need to buffer the output
|
||||
* we avoid a buffer copy if
|
||||
* we do not need to buffer the output
|
||||
* or the incoming buf is a single and our buffer is empty
|
||||
*/
|
||||
|
||||
while (in) {
|
||||
if (ngx_buf_special(in->buf)) {
|
||||
in = in->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
n = ngx_ssl_write(c, in->buf->pos, in->buf->last - in->buf->pos);
|
||||
|
||||
if (n == NGX_ERROR) {
|
||||
@ -538,6 +607,11 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
|
||||
in->buf->pos += n;
|
||||
|
||||
if (in->buf->pos == in->buf->last) {
|
||||
in = in->next;
|
||||
}
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
@ -549,6 +623,7 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
}
|
||||
|
||||
|
||||
buf = c->ssl->buf;
|
||||
send = 0;
|
||||
flush = (in == NULL) ? 1 : 0;
|
||||
|
||||
@ -576,7 +651,7 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
*/
|
||||
|
||||
if (send + size > limit) {
|
||||
size = limit - send;
|
||||
size = (ssize_t) (limit - send);
|
||||
flush = 1;
|
||||
}
|
||||
|
||||
@ -588,6 +663,7 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
buf->last += size;
|
||||
|
||||
in->buf->pos += size;
|
||||
|
||||
if (in->buf->pos == in->buf->last) {
|
||||
in = in->next;
|
||||
}
|
||||
@ -678,7 +754,7 @@ ngx_ssl_write(ngx_connection_t *c, u_char *data, size_t size)
|
||||
if (sslerr == SSL_ERROR_WANT_READ) {
|
||||
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, 0,
|
||||
"client started SSL renegotiation");
|
||||
"peer started SSL renegotiation");
|
||||
|
||||
c->read->ready = 0;
|
||||
|
||||
@ -725,7 +801,7 @@ ngx_ssl_shutdown(ngx_connection_t *c)
|
||||
int n, sslerr, mode;
|
||||
ngx_uint_t again;
|
||||
|
||||
if (c->read->timedout) {
|
||||
if (c->timedout) {
|
||||
mode = SSL_RECEIVED_SHUTDOWN|SSL_SENT_SHUTDOWN;
|
||||
|
||||
} else {
|
||||
@ -752,7 +828,7 @@ ngx_ssl_shutdown(ngx_connection_t *c)
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_shutdown: %d", n);
|
||||
|
||||
if (n == 1 || (n == 0 && c->read->timedout)) {
|
||||
if (n == 1 || (n == 0 && c->timedout)) {
|
||||
SSL_free(c->ssl->connection);
|
||||
c->ssl = NULL;
|
||||
|
||||
@ -778,6 +854,8 @@ ngx_ssl_shutdown(ngx_connection_t *c)
|
||||
|
||||
ngx_add_timer(c->read, 30000);
|
||||
|
||||
c->read->handler = ngx_ssl_shutdown_handler;
|
||||
|
||||
if (ngx_handle_read_event(c->read, 0) == NGX_ERROR) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
@ -787,6 +865,8 @@ ngx_ssl_shutdown(ngx_connection_t *c)
|
||||
|
||||
if (sslerr == SSL_ERROR_WANT_WRITE) {
|
||||
|
||||
c->write->handler = ngx_ssl_shutdown_handler;
|
||||
|
||||
if (ngx_handle_write_event(c->write, 0) == NGX_ERROR) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
@ -803,6 +883,29 @@ ngx_ssl_shutdown(ngx_connection_t *c)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ngx_ssl_shutdown_handler(ngx_event_t *ev)
|
||||
{
|
||||
ngx_connection_t *c;
|
||||
ngx_connection_handler_pt handler;
|
||||
|
||||
c = ev->data;
|
||||
handler = c->ssl->handler;
|
||||
|
||||
if (ev->timedout) {
|
||||
c->timedout = 1;
|
||||
}
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, "SSL shutdown handler");
|
||||
|
||||
if (ngx_ssl_shutdown(c) == NGX_AGAIN) {
|
||||
return;
|
||||
}
|
||||
|
||||
handler(c);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ngx_ssl_connection_error(ngx_connection_t *c, int sslerr, ngx_err_t err,
|
||||
char *text)
|
||||
|
@ -46,12 +46,16 @@ typedef struct {
|
||||
} ngx_ssl_connection_t;
|
||||
|
||||
|
||||
#define ngx_ssl_session_t SSL_SESSION
|
||||
|
||||
|
||||
#define NGX_SSL_SSLv2 2
|
||||
#define NGX_SSL_SSLv3 4
|
||||
#define NGX_SSL_TLSv1 8
|
||||
|
||||
|
||||
#define NGX_SSL_BUFFER 1
|
||||
#define NGX_SSL_CLIENT 2
|
||||
|
||||
#define NGX_SSL_BUFSIZE 16384
|
||||
|
||||
@ -63,9 +67,15 @@ ngx_int_t ngx_ssl_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl,
|
||||
ngx_int_t ngx_ssl_generate_rsa512_key(ngx_ssl_t *ssl);
|
||||
ngx_int_t ngx_ssl_create_connection(ngx_ssl_t *ssl, ngx_connection_t *c,
|
||||
ngx_uint_t flags);
|
||||
|
||||
ngx_int_t ngx_ssl_set_session(ngx_connection_t *c, ngx_ssl_session_t *session);
|
||||
#define ngx_ssl_get_session(c) SSL_get1_session(c->ssl->connection)
|
||||
#define ngx_ssl_free_session SSL_SESSION_free
|
||||
|
||||
ngx_int_t ngx_ssl_handshake(ngx_connection_t *c);
|
||||
ssize_t ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size);
|
||||
ssize_t ngx_ssl_write(ngx_connection_t *c, u_char *data, size_t size);
|
||||
ssize_t ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl);
|
||||
ngx_chain_t *ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in,
|
||||
off_t limit);
|
||||
ngx_int_t ngx_ssl_shutdown(ngx_connection_t *c);
|
||||
|
@ -20,7 +20,8 @@ static ngx_inline void ngx_event_pipe_free_shadow_raw_buf(ngx_chain_t **free,
|
||||
static ngx_int_t ngx_event_pipe_drain_chains(ngx_event_pipe_t *p);
|
||||
|
||||
|
||||
ngx_int_t ngx_event_pipe(ngx_event_pipe_t *p, int do_write)
|
||||
ngx_int_t
|
||||
ngx_event_pipe(ngx_event_pipe_t *p, int do_write)
|
||||
{
|
||||
u_int flags;
|
||||
ngx_event_t *rev, *wev;
|
||||
@ -79,7 +80,8 @@ ngx_int_t ngx_event_pipe(ngx_event_pipe_t *p, int do_write)
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
||||
static ngx_int_t
|
||||
ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
||||
{
|
||||
ssize_t n, size;
|
||||
ngx_int_t rc;
|
||||
@ -123,7 +125,7 @@ static ngx_int_t ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
||||
/*
|
||||
* kqueue notifies about the end of file or a pending error.
|
||||
* This test allows not to allocate a buf on these conditions
|
||||
* and not to call ngx_recv_chain().
|
||||
* and not to call c->recv_chain().
|
||||
*/
|
||||
|
||||
if (p->upstream->read->available == 0
|
||||
@ -250,7 +252,7 @@ static ngx_int_t ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
||||
break;
|
||||
}
|
||||
|
||||
n = ngx_recv_chain(p->upstream, chain);
|
||||
n = p->upstream->recv_chain(p->upstream, chain);
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
||||
"pipe recv chain: %z", n);
|
||||
@ -398,7 +400,8 @@ static ngx_int_t ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
||||
static ngx_int_t
|
||||
ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
||||
{
|
||||
size_t bsize;
|
||||
ngx_uint_t flush;
|
||||
@ -578,7 +581,8 @@ static ngx_int_t ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p)
|
||||
static ngx_int_t
|
||||
ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p)
|
||||
{
|
||||
ssize_t size, bsize;
|
||||
ngx_buf_t *b;
|
||||
@ -704,7 +708,8 @@ static ngx_int_t ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p)
|
||||
|
||||
/* the copy input filter */
|
||||
|
||||
ngx_int_t ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
||||
ngx_int_t
|
||||
ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
||||
{
|
||||
ngx_buf_t *b;
|
||||
ngx_chain_t *cl;
|
||||
@ -754,7 +759,8 @@ ngx_int_t ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
||||
}
|
||||
|
||||
|
||||
static ngx_inline void ngx_event_pipe_remove_shadow_links(ngx_buf_t *buf)
|
||||
static ngx_inline void
|
||||
ngx_event_pipe_remove_shadow_links(ngx_buf_t *buf)
|
||||
{
|
||||
ngx_buf_t *b, *next;
|
||||
|
||||
@ -784,8 +790,8 @@ static ngx_inline void ngx_event_pipe_remove_shadow_links(ngx_buf_t *buf)
|
||||
}
|
||||
|
||||
|
||||
static ngx_inline void ngx_event_pipe_free_shadow_raw_buf(ngx_chain_t **free,
|
||||
ngx_buf_t *buf)
|
||||
static ngx_inline void
|
||||
ngx_event_pipe_free_shadow_raw_buf(ngx_chain_t **free, ngx_buf_t *buf)
|
||||
{
|
||||
ngx_buf_t *s;
|
||||
ngx_chain_t *cl, **ll;
|
||||
@ -813,7 +819,8 @@ static ngx_inline void ngx_event_pipe_free_shadow_raw_buf(ngx_chain_t **free,
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t ngx_event_pipe_add_free_buf(ngx_event_pipe_t *p, ngx_buf_t *b)
|
||||
ngx_int_t
|
||||
ngx_event_pipe_add_free_buf(ngx_event_pipe_t *p, ngx_buf_t *b)
|
||||
{
|
||||
ngx_chain_t *cl;
|
||||
|
||||
@ -854,7 +861,8 @@ ngx_int_t ngx_event_pipe_add_free_buf(ngx_event_pipe_t *p, ngx_buf_t *b)
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t ngx_event_pipe_drain_chains(ngx_event_pipe_t *p)
|
||||
static ngx_int_t
|
||||
ngx_event_pipe_drain_chains(ngx_event_pipe_t *p)
|
||||
{
|
||||
ngx_chain_t *cl, *tl;
|
||||
|
||||
|
173
src/http/modules/ngx_http_empty_gif_module.c
Normal file
173
src/http/modules/ngx_http_empty_gif_module.c
Normal file
@ -0,0 +1,173 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) Igor Sysoev
|
||||
*/
|
||||
|
||||
#include <ngx_config.h>
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_http.h>
|
||||
|
||||
|
||||
static char *ngx_http_empty_gif(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
void *conf);
|
||||
|
||||
static ngx_command_t ngx_http_empty_gif_commands[] = {
|
||||
|
||||
{ ngx_string("empty_gif"),
|
||||
NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS,
|
||||
ngx_http_empty_gif,
|
||||
0,
|
||||
0,
|
||||
NULL },
|
||||
|
||||
ngx_null_command
|
||||
};
|
||||
|
||||
|
||||
/* the minimal single pixel transparent GIF, 43 bytes */
|
||||
|
||||
static u_char ngx_empty_gif[] = {
|
||||
|
||||
'G', 'I', 'F', '8', '9', 'a', /* header */
|
||||
|
||||
/* logical screen descriptor */
|
||||
0x01, 0x00, /* logical screen width */
|
||||
0x01, 0x00, /* logical screen height */
|
||||
0x80, /* global 1-bit color table */
|
||||
0x01, /* background color #1 */
|
||||
0x00, /* no aspect ratio */
|
||||
|
||||
/* global color table */
|
||||
0x00, 0x00, 0x00, /* #0: black */
|
||||
0xff, 0xff, 0xff, /* #1: white */
|
||||
|
||||
/* graphic control extension */
|
||||
0x21, /* extension introducer */
|
||||
0xf9, /* graphic control label */
|
||||
0x04, /* block size */
|
||||
0x01, /* transparent color is given, */
|
||||
/* no disposal specified, */
|
||||
/* user input is not expected */
|
||||
0x00, 0x00, /* delay time */
|
||||
0x01, /* transparent color #1 */
|
||||
0x00, /* block terminator */
|
||||
|
||||
/* image descriptor */
|
||||
0x2c, /* image separator */
|
||||
0x00, 0x00, /* image left position */
|
||||
0x00, 0x00, /* image top position */
|
||||
0x01, 0x00, /* image width */
|
||||
0x01, 0x00, /* image height */
|
||||
0x00, /* no local color table, no interlaced */
|
||||
|
||||
/* table based image data */
|
||||
0x02, /* LZW minimum code size, */
|
||||
/* must be at least 2-bit */
|
||||
0x02, /* block size */
|
||||
0x4c, 0x01, /* compressed bytes 01_001_100, 0000000_1 */
|
||||
/* 100: clear code */
|
||||
/* 001: 1 */
|
||||
/* 101: end of information code */
|
||||
0x00, /* block terminator */
|
||||
|
||||
0x3B /* trailer */
|
||||
};
|
||||
|
||||
|
||||
ngx_http_module_t ngx_http_empty_gif_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
||||
NULL, /* create server configuration */
|
||||
NULL, /* merge server configuration */
|
||||
|
||||
NULL, /* create location configuration */
|
||||
NULL /* merge location configuration */
|
||||
};
|
||||
|
||||
|
||||
ngx_module_t ngx_http_empty_gif_module = {
|
||||
NGX_MODULE_V1,
|
||||
&ngx_http_empty_gif_module_ctx, /* module context */
|
||||
ngx_http_empty_gif_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
NULL, /* exit process */
|
||||
NULL, /* exit master */
|
||||
NGX_MODULE_V1_PADDING
|
||||
};
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_empty_gif_handler(ngx_http_request_t *r)
|
||||
{
|
||||
ngx_int_t rc;
|
||||
ngx_buf_t *b;
|
||||
ngx_chain_t out;
|
||||
|
||||
if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) {
|
||||
return NGX_HTTP_NOT_ALLOWED;
|
||||
}
|
||||
|
||||
rc = ngx_http_discard_body(r);
|
||||
|
||||
if (rc != NGX_OK && rc != NGX_AGAIN) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
r->headers_out.content_type.len = sizeof("image/gif") - 1;
|
||||
r->headers_out.content_type.data = (u_char *) "image/gif";
|
||||
|
||||
if (r->method == NGX_HTTP_HEAD) {
|
||||
r->headers_out.status = NGX_HTTP_OK;
|
||||
|
||||
rc = ngx_http_send_header(r);
|
||||
|
||||
if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
b = ngx_create_temp_buf(r->pool, sizeof(ngx_empty_gif));
|
||||
if (b == NULL) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
out.buf = b;
|
||||
out.next = NULL;
|
||||
|
||||
b->pos = ngx_empty_gif;
|
||||
b->last = ngx_empty_gif + sizeof(ngx_empty_gif);
|
||||
b->last_buf = 1;
|
||||
|
||||
r->headers_out.status = NGX_HTTP_OK;
|
||||
r->headers_out.content_length_n = b->last - b->pos;
|
||||
r->headers_out.last_modified_time = 23349600;
|
||||
|
||||
rc = ngx_http_send_header(r);
|
||||
|
||||
if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
return ngx_http_output_filter(r, &out);;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
ngx_http_empty_gif(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
|
||||
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
||||
clcf->handler = ngx_http_empty_gif_handler;
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
@ -64,10 +64,6 @@ ngx_module_t ngx_http_geo_module = {
|
||||
};
|
||||
|
||||
|
||||
static ngx_http_variable_value_t ngx_http_geo_null_value =
|
||||
ngx_http_variable("");
|
||||
|
||||
|
||||
/* AF_INET only */
|
||||
|
||||
static ngx_int_t
|
||||
@ -171,7 +167,8 @@ ngx_http_geo_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
}
|
||||
|
||||
if (ngx_radix32tree_insert(tree, 0, 0,
|
||||
(uintptr_t) &ngx_http_geo_null_value) == NGX_ERROR)
|
||||
(uintptr_t) &ngx_http_variable_null_value)
|
||||
== NGX_ERROR)
|
||||
{
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
@ -358,15 +358,12 @@ found:
|
||||
r->headers_out.content_encoding->value.data = (u_char *) "gzip";
|
||||
|
||||
ctx->length = r->headers_out.content_length_n;
|
||||
r->headers_out.content_length_n = -1;
|
||||
|
||||
if (r->headers_out.content_length) {
|
||||
r->headers_out.content_length->hash = 0;
|
||||
r->headers_out.content_length = NULL;
|
||||
}
|
||||
|
||||
r->main_filter_need_in_memory = 1;
|
||||
|
||||
ngx_http_clear_content_length(r);
|
||||
ngx_http_clear_accept_ranges(r);
|
||||
|
||||
return ngx_http_next_header_filter(r);
|
||||
}
|
||||
|
||||
@ -1096,7 +1093,7 @@ ngx_http_gzip_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||
ngx_conf_merge_size_value(conf->wbits, prev->wbits, MAX_WBITS);
|
||||
ngx_conf_merge_size_value(conf->memlevel, prev->memlevel,
|
||||
MAX_MEM_LEVEL - 1);
|
||||
ngx_conf_merge_value(conf->min_length, prev->min_length, 0);
|
||||
ngx_conf_merge_value(conf->min_length, prev->min_length, 20);
|
||||
ngx_conf_merge_value(conf->no_buffer, prev->no_buffer, 0);
|
||||
|
||||
if (conf->types == NULL) {
|
||||
|
@ -55,7 +55,7 @@ static u_char *ngx_http_log_status(ngx_http_request_t *r, u_char *buf,
|
||||
ngx_http_log_op_t *op);
|
||||
static u_char *ngx_http_log_bytes_sent(ngx_http_request_t *r, u_char *buf,
|
||||
ngx_http_log_op_t *op);
|
||||
static u_char *ngx_http_log_apache_bytes_sent(ngx_http_request_t *r,
|
||||
static u_char *ngx_http_log_body_bytes_sent(ngx_http_request_t *r,
|
||||
u_char *buf, ngx_http_log_op_t *op);
|
||||
static u_char *ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf,
|
||||
ngx_http_log_op_t *op);
|
||||
@ -173,7 +173,7 @@ static ngx_str_t http_access_log = ngx_string(NGX_HTTP_LOG_PATH);
|
||||
|
||||
static ngx_str_t ngx_http_combined_fmt =
|
||||
ngx_string("$remote_addr - $remote_user [$time_gmt] "
|
||||
"\"$request\" $status $apache_bytes_sent "
|
||||
"\"$request\" $status $body_bytes_sent "
|
||||
"\"$http_referer\" \"$http_user_agent\"");
|
||||
|
||||
|
||||
@ -186,8 +186,10 @@ static ngx_http_log_var_t ngx_http_log_vars[] = {
|
||||
{ ngx_string("request_time"), NGX_TIME_T_LEN, ngx_http_log_request_time },
|
||||
{ ngx_string("status"), 3, ngx_http_log_status },
|
||||
{ ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent },
|
||||
{ ngx_string("body_bytes_sent"), NGX_OFF_T_LEN,
|
||||
ngx_http_log_body_bytes_sent },
|
||||
{ ngx_string("apache_bytes_sent"), NGX_OFF_T_LEN,
|
||||
ngx_http_log_apache_bytes_sent },
|
||||
ngx_http_log_body_bytes_sent },
|
||||
{ ngx_string("request_length"), NGX_SIZE_T_LEN,
|
||||
ngx_http_log_request_length },
|
||||
|
||||
@ -209,7 +211,7 @@ ngx_http_log_op_name_t ngx_http_log_fmt_ops[] = {
|
||||
{ ngx_string("length"), NGX_OFF_T_LEN,
|
||||
NULL, NULL, ngx_http_log_bytes_sent },
|
||||
{ ngx_string("apache_length"), NGX_OFF_T_LEN,
|
||||
NULL, NULL, ngx_http_log_apache_bytes_sent },
|
||||
NULL, NULL, ngx_http_log_body_bytes_sent },
|
||||
{ ngx_string("request_length"), NGX_SIZE_T_LEN,
|
||||
NULL, NULL, ngx_http_log_request_length },
|
||||
|
||||
@ -429,7 +431,7 @@ ngx_http_log_bytes_sent(ngx_http_request_t *r, u_char *buf,
|
||||
|
||||
|
||||
static u_char *
|
||||
ngx_http_log_apache_bytes_sent(ngx_http_request_t *r, u_char *buf,
|
||||
ngx_http_log_body_bytes_sent(ngx_http_request_t *r, u_char *buf,
|
||||
ngx_http_log_op_t *op)
|
||||
{
|
||||
off_t length;
|
||||
@ -1298,6 +1300,12 @@ ngx_http_log_compile_format(ngx_conf_t *cf, ngx_array_t *ops,
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (ngx_strncmp(var.data, "apache_bytes_sent", 17) == 0) {
|
||||
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
||||
"use \"$body_bytes_sent\" instead of "
|
||||
"\"$apache_bytes_sent\"");
|
||||
}
|
||||
|
||||
for (v = ngx_http_log_vars; v->name.len; v++) {
|
||||
|
||||
if (v->name.len == var.len
|
||||
|
@ -72,11 +72,8 @@ static ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r)
|
||||
if (ims != NGX_ERROR && ims == r->headers_out.last_modified_time) {
|
||||
r->headers_out.status = NGX_HTTP_NOT_MODIFIED;
|
||||
r->headers_out.content_type.len = 0;
|
||||
r->headers_out.content_length_n = -1;
|
||||
r->headers_out.content_length = NULL;
|
||||
#if 0
|
||||
r->headers_out.accept_ranges->hash = 0;
|
||||
#endif
|
||||
ngx_http_clear_content_length(r);
|
||||
ngx_http_clear_accept_ranges(r);
|
||||
}
|
||||
|
||||
return ngx_http_next_header_filter(r);
|
||||
|
@ -38,6 +38,8 @@ typedef struct {
|
||||
ngx_peers_t *peers;
|
||||
|
||||
ngx_array_t *flushes;
|
||||
ngx_array_t *body_set_len;
|
||||
ngx_array_t *body_set;
|
||||
ngx_array_t *headers_set_len;
|
||||
ngx_array_t *headers_set;
|
||||
ngx_hash_t *headers_set_hash;
|
||||
@ -47,6 +49,8 @@ typedef struct {
|
||||
|
||||
ngx_array_t *redirects;
|
||||
|
||||
ngx_str_t body_source;
|
||||
|
||||
ngx_str_t method;
|
||||
ngx_str_t host_header;
|
||||
ngx_str_t port_text;
|
||||
@ -60,6 +64,8 @@ typedef struct {
|
||||
ngx_uint_t status_count;
|
||||
u_char *status_start;
|
||||
u_char *status_end;
|
||||
|
||||
size_t internal_body_length;
|
||||
} ngx_http_proxy_ctx_t;
|
||||
|
||||
|
||||
@ -83,6 +89,9 @@ static ngx_int_t ngx_http_proxy_port_variable(ngx_http_request_t *r,
|
||||
static ngx_int_t
|
||||
ngx_http_proxy_add_x_forwarded_for_variable(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data);
|
||||
static ngx_int_t
|
||||
ngx_http_proxy_internal_body_length_variable(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data);
|
||||
static ngx_int_t ngx_http_proxy_rewrite_redirect(ngx_http_request_t *r,
|
||||
ngx_table_elt_t *h, size_t prefix);
|
||||
|
||||
@ -164,6 +173,13 @@ static ngx_command_t ngx_http_proxy_commands[] = {
|
||||
offsetof(ngx_http_proxy_loc_conf_t, headers_source),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("proxy_set_body"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_str_slot,
|
||||
NGX_HTTP_LOC_CONF_OFFSET,
|
||||
offsetof(ngx_http_proxy_loc_conf_t, body_source),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("proxy_method"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_str_slot,
|
||||
@ -336,6 +352,9 @@ static ngx_http_variable_t ngx_http_proxy_vars[] = {
|
||||
{ ngx_string("proxy_add_via"), NULL, 0, 0, 0 },
|
||||
#endif
|
||||
|
||||
{ ngx_string("proxy_internal_body_length"),
|
||||
ngx_http_proxy_internal_body_length_variable, 0, 0, 0 },
|
||||
|
||||
{ ngx_null_string, NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
@ -395,7 +414,7 @@ ngx_http_proxy_handler(ngx_http_request_t *r)
|
||||
static ngx_int_t
|
||||
ngx_http_proxy_create_request(ngx_http_request_t *r)
|
||||
{
|
||||
size_t len, loc_len;
|
||||
size_t len, loc_len, body_len;
|
||||
ngx_uint_t i, key;
|
||||
uintptr_t escape;
|
||||
ngx_buf_t *b;
|
||||
@ -404,6 +423,7 @@ ngx_http_proxy_create_request(ngx_http_request_t *r)
|
||||
ngx_list_part_t *part;
|
||||
ngx_table_elt_t *header;
|
||||
ngx_http_upstream_t *u;
|
||||
ngx_http_proxy_ctx_t *p;
|
||||
ngx_http_script_code_pt code;
|
||||
ngx_http_script_engine_t e, le;
|
||||
ngx_http_proxy_loc_conf_t *plcf;
|
||||
@ -413,6 +433,13 @@ ngx_http_proxy_create_request(ngx_http_request_t *r)
|
||||
|
||||
plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module);
|
||||
|
||||
p = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_ctx_t));
|
||||
if (p == NULL) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
ngx_http_set_ctx(r, p, ngx_http_proxy_module);
|
||||
|
||||
len = sizeof(ngx_http_proxy_version) - 1 + sizeof(CRLF) - 1;
|
||||
|
||||
if (u->method.len) {
|
||||
@ -446,10 +473,23 @@ ngx_http_proxy_create_request(ngx_http_request_t *r)
|
||||
len += r->uri.len - loc_len + escape + sizeof("?") - 1 + r->args.len;
|
||||
}
|
||||
|
||||
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
|
||||
|
||||
ngx_http_script_flush_no_cachable_variables(r, plcf->flushes);
|
||||
|
||||
if (plcf->body_set_len) {
|
||||
le.ip = plcf->body_set_len->elts;
|
||||
le.request = r;
|
||||
le.flushed = 1;
|
||||
body_len = 0;
|
||||
|
||||
while (*(uintptr_t *) le.ip) {
|
||||
lcode = *(ngx_http_script_len_code_pt *) le.ip;
|
||||
body_len += lcode(&le);
|
||||
}
|
||||
|
||||
p->internal_body_length = body_len;
|
||||
len += body_len;
|
||||
}
|
||||
|
||||
le.ip = plcf->headers_set_len->elts;
|
||||
le.request = r;
|
||||
le.flushed = 1;
|
||||
@ -543,6 +583,7 @@ ngx_http_proxy_create_request(ngx_http_request_t *r)
|
||||
b->last = ngx_cpymem(b->last, ngx_http_proxy_version,
|
||||
sizeof(ngx_http_proxy_version) - 1);
|
||||
|
||||
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
|
||||
|
||||
e.ip = plcf->headers_set->elts;
|
||||
e.pos = b->last;
|
||||
@ -620,9 +661,22 @@ ngx_http_proxy_create_request(ngx_http_request_t *r)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* add "\r\n" at the header end */
|
||||
*b->last++ = CR; *b->last++ = LF;
|
||||
|
||||
if (plcf->body_set) {
|
||||
e.ip = plcf->body_set->elts;
|
||||
e.pos = b->last;
|
||||
|
||||
while (*(uintptr_t *) e.ip) {
|
||||
code = *(ngx_http_script_code_pt *) e.ip;
|
||||
code((ngx_http_script_engine_t *) &e);
|
||||
}
|
||||
}
|
||||
|
||||
b->last = e.pos;
|
||||
|
||||
#if (NGX_DEBUG)
|
||||
{
|
||||
ngx_str_t s;
|
||||
@ -634,7 +688,7 @@ ngx_http_proxy_create_request(ngx_http_request_t *r)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (plcf->upstream.pass_request_body) {
|
||||
if (plcf->body_set == NULL && plcf->upstream.pass_request_body) {
|
||||
|
||||
body = u->request_bufs;
|
||||
u->request_bufs = cl;
|
||||
@ -699,15 +753,10 @@ ngx_http_proxy_process_status_line(ngx_http_request_t *r)
|
||||
|
||||
p = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
|
||||
|
||||
if (p == NULL) {
|
||||
p = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_ctx_t));
|
||||
if (p == NULL) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
ngx_http_set_ctx(r, p, ngx_http_proxy_module);
|
||||
}
|
||||
|
||||
rc = ngx_http_proxy_parse_status_line(r, p);
|
||||
|
||||
if (rc == NGX_AGAIN) {
|
||||
@ -1097,7 +1146,6 @@ ngx_http_proxy_port_variable(ngx_http_request_t *r,
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_proxy_add_x_forwarded_for_variable(ngx_http_request_t *r,
|
||||
|
||||
ngx_http_variable_value_t *v, uintptr_t data)
|
||||
{
|
||||
u_char *p;
|
||||
@ -1133,6 +1181,35 @@ ngx_http_proxy_add_x_forwarded_for_variable(ngx_http_request_t *r,
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_proxy_internal_body_length_variable(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data)
|
||||
{
|
||||
ngx_http_proxy_ctx_t *p;
|
||||
|
||||
p = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
|
||||
|
||||
if (p == NULL) {
|
||||
v->not_found = 1;
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
v->valid = 1;
|
||||
v->no_cachable = 0;
|
||||
v->not_found = 0;
|
||||
|
||||
v->data = ngx_palloc(r->connection->pool, NGX_SIZE_T_LEN);
|
||||
|
||||
if (v->data == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
v->len = ngx_sprintf(v->data, "%uz", p->internal_body_length) - v->data;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_proxy_rewrite_redirect(ngx_http_request_t *r, ngx_table_elt_t *h,
|
||||
size_t prefix)
|
||||
@ -1294,6 +1371,9 @@ ngx_http_proxy_create_loc_conf(ngx_conf_t *cf)
|
||||
* conf->headers_set_len = NULL;
|
||||
* conf->headers_set = NULL;
|
||||
* conf->headers_set_hash = NULL;
|
||||
* conf->body_set_len = NULL;
|
||||
* conf->body_set = NULL;
|
||||
* conf->body_source = { 0, NULL };
|
||||
* conf->rewrite_locations = NULL;
|
||||
*/
|
||||
|
||||
@ -1534,6 +1614,50 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||
conf->peers = prev->peers;
|
||||
}
|
||||
|
||||
|
||||
if (conf->body_source.data == NULL) {
|
||||
conf->body_source = prev->body_source;
|
||||
conf->body_set_len = prev->body_set_len;
|
||||
conf->body_set = prev->body_set;
|
||||
}
|
||||
|
||||
if (conf->body_set_len == 0) {
|
||||
|
||||
ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
|
||||
|
||||
sc.cf = cf;
|
||||
sc.source = &conf->body_source;
|
||||
sc.flushes = &conf->flushes;
|
||||
sc.lengths = &conf->body_set_len;
|
||||
sc.values = &conf->body_set;
|
||||
sc.complete_lengths = 1;
|
||||
sc.complete_values = 1;
|
||||
|
||||
if (ngx_http_script_compile(&sc) != NGX_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (conf->headers_source == NULL) {
|
||||
conf->headers_source = ngx_array_create(cf->pool, 4,
|
||||
sizeof(ngx_table_elt_t));
|
||||
if (conf->headers_source == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
s = ngx_array_push(conf->headers_source);
|
||||
if (s == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
s->hash = 0;
|
||||
s->key.len = sizeof("Content-Length") - 1;
|
||||
s->key.data = (u_char *) "Content-Length";
|
||||
s->value.len = sizeof("$proxy_internal_body_length") - 1;
|
||||
s->value.data = (u_char *) "$proxy_internal_body_length";
|
||||
}
|
||||
|
||||
|
||||
if (conf->headers_source == NULL) {
|
||||
conf->flushes = prev->flushes;
|
||||
conf->headers_set_len = prev->headers_set_len;
|
||||
@ -1595,6 +1719,8 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
src = conf->headers_source->elts;
|
||||
for (i = 0; i < conf->headers_source->nelts; i++) {
|
||||
|
||||
name = ngx_array_push(conf->headers_names);
|
||||
@ -1766,9 +1892,13 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
ngx_http_proxy_loc_conf_t *plcf = conf;
|
||||
|
||||
size_t add;
|
||||
ngx_str_t *value, *url;
|
||||
ngx_inet_upstream_t inet_upstream;
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
#if (NGX_HTTP_SSL)
|
||||
ngx_pool_cleanup_t *cln;
|
||||
#endif
|
||||
#if (NGX_HAVE_UNIX_DOMAIN)
|
||||
ngx_unix_domain_upstream_t unix_upstream;
|
||||
#endif
|
||||
@ -1781,20 +1911,57 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
|
||||
url = &value[1];
|
||||
|
||||
if (ngx_strncasecmp(url->data, "http://", 7) != 0) {
|
||||
if (ngx_strncasecmp(url->data, "http://", 7) == 0) {
|
||||
add = 7;
|
||||
|
||||
} else if (ngx_strncasecmp(url->data, "https://", 8) == 0) {
|
||||
|
||||
#if (NGX_HTTP_SSL)
|
||||
|
||||
add = 8;
|
||||
|
||||
plcf->upstream.ssl = ngx_pcalloc(cf->pool, sizeof(ngx_ssl_t));
|
||||
if (plcf->upstream.ssl == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
plcf->upstream.ssl->log = cf->log;
|
||||
|
||||
if (ngx_ssl_create(plcf->upstream.ssl,
|
||||
NGX_SSL_SSLv2|NGX_SSL_SSLv3|NGX_SSL_TLSv1)
|
||||
!= NGX_OK)
|
||||
{
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
cln = ngx_pool_cleanup_add(cf->pool, 0);
|
||||
if (cln == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
cln->handler = ngx_ssl_cleanup_ctx;
|
||||
cln->data = plcf->upstream.ssl;
|
||||
|
||||
#else
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"https protocol requires SSL support");
|
||||
return NGX_CONF_ERROR;
|
||||
#endif
|
||||
|
||||
} else {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid URL prefix");
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_strncasecmp(url->data + 7, "unix:", 5) == 0) {
|
||||
if (ngx_strncasecmp(url->data + add, "unix:", 5) == 0) {
|
||||
|
||||
#if (NGX_HAVE_UNIX_DOMAIN)
|
||||
|
||||
ngx_memzero(&unix_upstream, sizeof(ngx_unix_domain_upstream_t));
|
||||
|
||||
unix_upstream.name = *url;
|
||||
unix_upstream.url.len = url->len - 7;
|
||||
unix_upstream.url.data = url->data + 7;
|
||||
unix_upstream.url.len = url->len - add;
|
||||
unix_upstream.url.data = url->data + add;
|
||||
unix_upstream.uri_part = 1;
|
||||
|
||||
plcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream);
|
||||
@ -1818,8 +1985,8 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
ngx_memzero(&inet_upstream, sizeof(ngx_inet_upstream_t));
|
||||
|
||||
inet_upstream.name = *url;
|
||||
inet_upstream.url.len = url->len - 7;
|
||||
inet_upstream.url.data = url->data + 7;
|
||||
inet_upstream.url.len = url->len - add;
|
||||
inet_upstream.url.data = url->data + add;
|
||||
inet_upstream.default_port_value = 80;
|
||||
inet_upstream.uri_part = 1;
|
||||
|
||||
|
@ -300,11 +300,7 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
|
||||
r->headers_out.content_length_n)
|
||||
- content_range->value.data;
|
||||
|
||||
r->headers_out.content_length_n = -1;
|
||||
if (r->headers_out.content_length) {
|
||||
r->headers_out.content_length->key.len = 0;
|
||||
r->headers_out.content_length = NULL;
|
||||
}
|
||||
ngx_http_clear_content_length(r);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
309
src/http/modules/ngx_http_referer_module.c
Normal file
309
src/http/modules/ngx_http_referer_module.c
Normal file
@ -0,0 +1,309 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) Igor Sysoev
|
||||
*/
|
||||
|
||||
|
||||
#include <ngx_config.h>
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_http.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_str_t name;
|
||||
ngx_uint_t wildcard;
|
||||
} ngx_http_referer_t;
|
||||
|
||||
typedef struct {
|
||||
ngx_array_t *referers; /* ngx_http_referer_t */
|
||||
|
||||
ngx_flag_t no_referer;
|
||||
ngx_flag_t blocked_referer;
|
||||
} ngx_http_referer_conf_t;
|
||||
|
||||
|
||||
static void * ngx_http_referer_create_conf(ngx_conf_t *cf);
|
||||
static char * ngx_http_referer_merge_conf(ngx_conf_t *cf, void *parent,
|
||||
void *child);
|
||||
static char *ngx_http_valid_referers(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
void *conf);
|
||||
|
||||
|
||||
static ngx_command_t ngx_http_referer_commands[] = {
|
||||
|
||||
{ ngx_string("valid_referers"),
|
||||
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
||||
ngx_http_valid_referers,
|
||||
NGX_HTTP_LOC_CONF_OFFSET,
|
||||
0,
|
||||
NULL },
|
||||
|
||||
ngx_null_command
|
||||
};
|
||||
|
||||
|
||||
static ngx_http_module_t ngx_http_referer_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
||||
NULL, /* create server configuration */
|
||||
NULL, /* merge server configuration */
|
||||
|
||||
ngx_http_referer_create_conf, /* create location configuration */
|
||||
ngx_http_referer_merge_conf /* merge location configuration */
|
||||
};
|
||||
|
||||
|
||||
ngx_module_t ngx_http_referer_module = {
|
||||
NGX_MODULE_V1,
|
||||
&ngx_http_referer_module_ctx, /* module context */
|
||||
ngx_http_referer_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
NULL, /* exit process */
|
||||
NULL, /* exit master */
|
||||
NGX_MODULE_V1_PADDING
|
||||
};
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_referer_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
||||
uintptr_t data)
|
||||
{
|
||||
u_char *ref;
|
||||
size_t len;
|
||||
ngx_uint_t i, n;
|
||||
ngx_http_referer_t *refs;
|
||||
ngx_http_referer_conf_t *cf;
|
||||
|
||||
cf = ngx_http_get_module_loc_conf(r, ngx_http_referer_module);
|
||||
|
||||
if (cf->referers == NULL) {
|
||||
*v = ngx_http_variable_null_value;
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
if (r->headers_in.referer == NULL) {
|
||||
if (cf->no_referer) {
|
||||
*v = ngx_http_variable_null_value;
|
||||
return NGX_OK;
|
||||
|
||||
} else {
|
||||
*v = ngx_http_variable_true_value;
|
||||
return NGX_OK;
|
||||
}
|
||||
}
|
||||
|
||||
len = r->headers_in.referer->value.len;
|
||||
ref = r->headers_in.referer->value.data;
|
||||
|
||||
if (len < sizeof("http://i.ru") - 1
|
||||
|| (ngx_strncasecmp(ref, "http://", 7) != 0))
|
||||
{
|
||||
if (cf->blocked_referer) {
|
||||
*v = ngx_http_variable_null_value;
|
||||
return NGX_OK;
|
||||
|
||||
} else {
|
||||
*v = ngx_http_variable_true_value;
|
||||
return NGX_OK;
|
||||
}
|
||||
}
|
||||
|
||||
len -= 7;
|
||||
ref += 7;
|
||||
|
||||
refs = cf->referers->elts;
|
||||
for (i = 0; i < cf->referers->nelts; i++ ){
|
||||
|
||||
if (refs[i].name.len > len) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (refs[i].wildcard) {
|
||||
for (n = 0; n < len; n++) {
|
||||
if (ref[n] == '/' || ref[n] == ':') {
|
||||
break;
|
||||
}
|
||||
|
||||
if (ref[n] != '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_strncmp(&ref[n], refs[i].name.data,
|
||||
refs[i].name.len) == 0)
|
||||
{
|
||||
*v = ngx_http_variable_null_value;
|
||||
return NGX_OK;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (ngx_strncasecmp(refs[i].name.data, ref, refs[i].name.len) == 0)
|
||||
{
|
||||
*v = ngx_http_variable_null_value;
|
||||
return NGX_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*v = ngx_http_variable_true_value;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
ngx_http_referer_create_conf(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_referer_conf_t *conf;
|
||||
|
||||
conf = ngx_palloc(cf->pool, sizeof(ngx_http_referer_conf_t));
|
||||
if (conf == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
conf->referers = NULL;
|
||||
conf->no_referer = NGX_CONF_UNSET;
|
||||
conf->blocked_referer = NGX_CONF_UNSET;
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
ngx_http_referer_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||
{
|
||||
ngx_http_referer_conf_t *prev = parent;
|
||||
ngx_http_referer_conf_t *conf = child;
|
||||
|
||||
if (conf->referers == NULL) {
|
||||
conf->referers = prev->referers;
|
||||
ngx_conf_merge_value(conf->no_referer, prev->no_referer, 0);
|
||||
ngx_conf_merge_value(conf->blocked_referer, prev->blocked_referer, 0);
|
||||
}
|
||||
|
||||
if (conf->no_referer == NGX_CONF_UNSET) {
|
||||
conf->no_referer = 0;
|
||||
}
|
||||
|
||||
if (conf->blocked_referer == NGX_CONF_UNSET) {
|
||||
conf->blocked_referer = 0;
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
ngx_http_valid_referers(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
ngx_http_referer_conf_t *lcf = conf;
|
||||
|
||||
ngx_uint_t i, server_names;
|
||||
ngx_str_t *value, name;
|
||||
ngx_http_referer_t *ref;
|
||||
ngx_http_variable_t *var;
|
||||
ngx_http_server_name_t *sn;
|
||||
ngx_http_core_srv_conf_t *cscf;
|
||||
|
||||
name.len = sizeof("invalid_referer") - 1;
|
||||
name.data = (u_char *) "invalid_referer";
|
||||
|
||||
var = ngx_http_add_variable(cf, &name, NGX_HTTP_VAR_CHANGABLE);
|
||||
if (var == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
var->handler = ngx_http_referer_variable;
|
||||
|
||||
cscf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_core_module);
|
||||
|
||||
if (lcf->referers == NULL) {
|
||||
lcf->referers = ngx_array_create(cf->pool,
|
||||
cf->args->nelts + cscf->server_names.nelts,
|
||||
sizeof(ngx_http_referer_t));
|
||||
if (lcf->referers == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
value = cf->args->elts;
|
||||
server_names = 0;
|
||||
|
||||
for (i = 1; i < cf->args->nelts; i++) {
|
||||
if (value[i].len == 0) {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"invalid referer \"%V\"", &value[i]);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_strcmp(value[i].data, "none") == 0) {
|
||||
lcf->no_referer = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_strcmp(value[i].data, "blocked") == 0) {
|
||||
lcf->blocked_referer = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_strcmp(value[i].data, "server_names") == 0) {
|
||||
server_names = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
ref = ngx_array_push(lcf->referers);
|
||||
if (ref == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (value[i].data[0] != '*') {
|
||||
ref->name = value[i];
|
||||
ref->wildcard = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (value[i].data[1] != '.') {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"invalid wildcard referer \"%V\"", &value[i]);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ref->name.len = value[i].len - 1;
|
||||
ref->name.data = value[i].data + 1;
|
||||
ref->wildcard = 1;
|
||||
}
|
||||
|
||||
if (!server_names) {
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
sn = cscf->server_names.elts;
|
||||
for (i = 0; i < cscf->server_names.nelts; i++) {
|
||||
ref = ngx_array_push(lcf->referers);
|
||||
if (ref == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ref->name.len = sn[i].name.len + 1;
|
||||
ref->name.data = ngx_palloc(cf->pool, ref->name.len);
|
||||
if (ref->name.data == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ngx_memcpy(ref->name.data, sn[i].name.data, sn[i].name.len);
|
||||
ref->name.data[sn[i].name.len] = '/';
|
||||
ref->wildcard = sn[i].wildcard;
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
@ -9,23 +9,13 @@
|
||||
#include <ngx_http.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_str_t name;
|
||||
ngx_uint_t wildcard;
|
||||
} ngx_http_rewrite_referer_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_array_t *codes; /* uintptr_t */
|
||||
ngx_array_t *referers; /* ngx_http_rewrite_referer_t */
|
||||
|
||||
ngx_uint_t captures;
|
||||
ngx_uint_t stack_size;
|
||||
|
||||
ngx_flag_t log;
|
||||
|
||||
ngx_flag_t no_referer;
|
||||
ngx_flag_t blocked_referer;
|
||||
} ngx_http_rewrite_loc_conf_t;
|
||||
|
||||
|
||||
@ -44,10 +34,10 @@ static char * ngx_http_rewrite_if_condition(ngx_conf_t *cf,
|
||||
ngx_http_rewrite_loc_conf_t *lcf);
|
||||
static char *ngx_http_rewrite_variable(ngx_conf_t *cf,
|
||||
ngx_http_rewrite_loc_conf_t *lcf, ngx_str_t *value);
|
||||
static char *ngx_http_rewrite_valid_referers(ngx_conf_t *cf,
|
||||
ngx_command_t *cmd, void *conf);
|
||||
static char *ngx_http_rewrite_set(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
void *conf);
|
||||
static char * ngx_http_rewrite_value(ngx_conf_t *cf,
|
||||
ngx_http_rewrite_loc_conf_t *lcf, ngx_str_t *value);
|
||||
|
||||
|
||||
static ngx_command_t ngx_http_rewrite_commands[] = {
|
||||
@ -83,12 +73,14 @@ static ngx_command_t ngx_http_rewrite_commands[] = {
|
||||
0,
|
||||
NULL },
|
||||
|
||||
#if 0
|
||||
{ ngx_string("valid_referers"),
|
||||
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
||||
ngx_http_rewrite_valid_referers,
|
||||
NGX_HTTP_LOC_CONF_OFFSET,
|
||||
0,
|
||||
NULL },
|
||||
#endif
|
||||
|
||||
{ ngx_string("set"),
|
||||
NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
||||
@ -141,10 +133,6 @@ ngx_module_t ngx_http_rewrite_module = {
|
||||
};
|
||||
|
||||
|
||||
static ngx_http_variable_value_t ngx_http_rewrite_null_value =
|
||||
ngx_http_variable("");
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_rewrite_handler(ngx_http_request_t *r)
|
||||
{
|
||||
@ -194,121 +182,6 @@ ngx_http_rewrite_handler(ngx_http_request_t *r)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ngx_http_rewrite_invalid_referer_code(ngx_http_script_engine_t *e)
|
||||
{
|
||||
u_char *ref;
|
||||
size_t len;
|
||||
ngx_uint_t i, n;
|
||||
ngx_http_request_t *r;
|
||||
ngx_http_rewrite_referer_t *refs;
|
||||
ngx_http_rewrite_loc_conf_t *cf;
|
||||
|
||||
r = e->request;
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"http rewrite invalid referer");
|
||||
|
||||
cf = ngx_http_get_module_loc_conf(r, ngx_http_rewrite_module);
|
||||
|
||||
e->ip += sizeof(uintptr_t);
|
||||
|
||||
if (cf->referers == NULL) {
|
||||
e->sp->data = (u_char *) "";
|
||||
e->sp->len = 0;
|
||||
e->sp++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (r->headers_in.referer == NULL) {
|
||||
if (cf->no_referer) {
|
||||
e->sp->data = (u_char *) "";
|
||||
e->sp->len = 0;
|
||||
e->sp++;
|
||||
|
||||
return;
|
||||
|
||||
} else {
|
||||
e->sp->data = (u_char *) "1";
|
||||
e->sp->len = 1;
|
||||
e->sp++;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
len = r->headers_in.referer->value.len;
|
||||
ref = r->headers_in.referer->value.data;
|
||||
|
||||
if (len < sizeof("http://i.ru") - 1
|
||||
|| (ngx_strncasecmp(ref, "http://", 7) != 0))
|
||||
{
|
||||
if (cf->blocked_referer) {
|
||||
e->sp->data = (u_char *) "";
|
||||
e->sp->len = 0;
|
||||
e->sp++;
|
||||
|
||||
return;
|
||||
|
||||
} else {
|
||||
e->sp->data = (u_char *) "1";
|
||||
e->sp->len = 1;
|
||||
e->sp++;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
len -= 7;
|
||||
ref += 7;
|
||||
|
||||
refs = cf->referers->elts;
|
||||
for (i = 0; i < cf->referers->nelts; i++ ){
|
||||
|
||||
if (refs[i].name.len > len) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (refs[i].wildcard) {
|
||||
for (n = 0; n < len; n++) {
|
||||
if (ref[n] == '/' || ref[n] == ':') {
|
||||
break;
|
||||
}
|
||||
|
||||
if (ref[n] != '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_strncmp(&ref[n], refs[i].name.data,
|
||||
refs[i].name.len) == 0)
|
||||
{
|
||||
e->sp->data = (u_char *) "";
|
||||
e->sp->len = 0;
|
||||
e->sp++;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (ngx_strncasecmp(refs[i].name.data, ref, refs[i].name.len) == 0)
|
||||
{
|
||||
e->sp->data = (u_char *) "";
|
||||
e->sp->len = 0;
|
||||
e->sp++;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e->sp->data = (u_char *) "1";
|
||||
e->sp->len = 1;
|
||||
e->sp++;
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_rewrite_var(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
||||
uintptr_t data)
|
||||
@ -329,7 +202,7 @@ ngx_http_rewrite_var(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
||||
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
|
||||
"using uninitialized \"%V\" variable", &var[data].name);
|
||||
|
||||
*v = ngx_http_rewrite_null_value;
|
||||
*v = ngx_http_variable_null_value;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
@ -347,8 +220,6 @@ ngx_http_rewrite_create_loc_conf(ngx_conf_t *cf)
|
||||
|
||||
conf->stack_size = NGX_CONF_UNSET_UINT;
|
||||
conf->log = NGX_CONF_UNSET;
|
||||
conf->no_referer = NGX_CONF_UNSET;
|
||||
conf->blocked_referer = NGX_CONF_UNSET;
|
||||
|
||||
return conf;
|
||||
}
|
||||
@ -365,20 +236,6 @@ ngx_http_rewrite_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||
ngx_conf_merge_value(conf->log, prev->log, 0);
|
||||
ngx_conf_merge_unsigned_value(conf->stack_size, prev->stack_size, 10);
|
||||
|
||||
if (conf->referers == NULL) {
|
||||
conf->referers = prev->referers;
|
||||
ngx_conf_merge_value(conf->no_referer, prev->no_referer, 0);
|
||||
ngx_conf_merge_value(conf->blocked_referer, prev->blocked_referer, 0);
|
||||
}
|
||||
|
||||
if (conf->no_referer == NGX_CONF_UNSET) {
|
||||
conf->no_referer = 0;
|
||||
}
|
||||
|
||||
if (conf->blocked_referer == NGX_CONF_UNSET) {
|
||||
conf->blocked_referer = 0;
|
||||
}
|
||||
|
||||
if (conf->codes == NULL) {
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
@ -774,6 +631,7 @@ ngx_http_rewrite_if_condition(ngx_conf_t *cf, ngx_http_rewrite_loc_conf_t *lcf)
|
||||
{
|
||||
ngx_str_t *value, err;
|
||||
ngx_uint_t cur, last, n;
|
||||
ngx_http_script_code_pt *code;
|
||||
ngx_http_script_regex_code_t *regex;
|
||||
u_char errstr[NGX_MAX_CONF_ERRSTR];
|
||||
|
||||
@ -817,7 +675,7 @@ ngx_http_rewrite_if_condition(ngx_conf_t *cf, ngx_http_rewrite_loc_conf_t *lcf)
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_http_rewrite_variable(cf, lcf, &value[cur])!= NGX_CONF_OK) {
|
||||
if (ngx_http_rewrite_variable(cf, lcf, &value[cur]) != NGX_CONF_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
@ -827,15 +685,44 @@ ngx_http_rewrite_if_condition(ngx_conf_t *cf, ngx_http_rewrite_loc_conf_t *lcf)
|
||||
|
||||
cur++;
|
||||
|
||||
if ((value[cur].len == 1 && value[cur].data[0] != '~')
|
||||
|| (value[cur].len == 2
|
||||
&& value[cur].data[0] != '~' && value[cur].data[1] != '*'))
|
||||
{
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"unexpected \"%V\" in condition", &value[cur]);
|
||||
if (value[cur].len == 1 && value[cur].data[0] == '=') {
|
||||
|
||||
if (ngx_http_rewrite_value(cf, lcf, &value[last]) != NGX_CONF_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
code = ngx_http_script_start_code(cf->pool, &lcf->codes,
|
||||
sizeof(uintptr_t));
|
||||
if (code == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
*code = ngx_http_script_equal_code;
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
if (value[cur].len == 2
|
||||
&& value[cur].data[0] == '!' && value[cur].data[1] == '=')
|
||||
{
|
||||
if (ngx_http_rewrite_value(cf, lcf, &value[last]) != NGX_CONF_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
code = ngx_http_script_start_code(cf->pool, &lcf->codes,
|
||||
sizeof(uintptr_t));
|
||||
if (code == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
*code = ngx_http_script_not_equal_code;
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
if ((value[cur].len == 1 && value[cur].data[0] == '~')
|
||||
|| (value[cur].len == 2
|
||||
&& value[cur].data[0] == '~' && value[cur].data[1] == '*'))
|
||||
{
|
||||
regex = ngx_http_script_start_code(cf->pool, &lcf->codes,
|
||||
sizeof(ngx_http_script_regex_code_t));
|
||||
if (regex == NULL) {
|
||||
@ -874,6 +761,11 @@ ngx_http_rewrite_if_condition(ngx_conf_t *cf, ngx_http_rewrite_loc_conf_t *lcf)
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"unexpected \"%V\" in condition", &value[cur]);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"invalid condition \"%V\"", &value[cur]);
|
||||
|
||||
@ -886,25 +778,11 @@ ngx_http_rewrite_variable(ngx_conf_t *cf, ngx_http_rewrite_loc_conf_t *lcf,
|
||||
ngx_str_t *value)
|
||||
{
|
||||
ngx_int_t index;
|
||||
ngx_http_script_code_pt *code;
|
||||
ngx_http_script_var_code_t *var_code;
|
||||
|
||||
value->len--;
|
||||
value->data++;
|
||||
|
||||
if (value->len == sizeof("invalid_referer") - 1
|
||||
&& ngx_strncmp(value->data, "invalid_referer",
|
||||
sizeof("invalid_referer") - 1) == 0)
|
||||
{
|
||||
code = ngx_http_script_start_code(cf->pool, &lcf->codes,
|
||||
sizeof(ngx_http_script_code_pt));
|
||||
if (code == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
*code = ngx_http_rewrite_invalid_referer_code;
|
||||
|
||||
} else {
|
||||
index = ngx_http_get_variable_index(cf, value);
|
||||
|
||||
if (index == NGX_ERROR) {
|
||||
@ -919,102 +797,6 @@ ngx_http_rewrite_variable(ngx_conf_t *cf, ngx_http_rewrite_loc_conf_t *lcf,
|
||||
|
||||
var_code->code = ngx_http_script_var_code;
|
||||
var_code->index = index;
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
ngx_http_rewrite_valid_referers(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
ngx_http_rewrite_loc_conf_t *lcf = conf;
|
||||
|
||||
ngx_uint_t i, server_names;
|
||||
ngx_str_t *value;
|
||||
ngx_http_server_name_t *sn;
|
||||
ngx_http_core_srv_conf_t *cscf;
|
||||
ngx_http_rewrite_referer_t *ref;
|
||||
|
||||
cscf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_core_module);
|
||||
|
||||
if (lcf->referers == NULL) {
|
||||
lcf->referers = ngx_array_create(cf->pool,
|
||||
cf->args->nelts + cscf->server_names.nelts,
|
||||
sizeof(ngx_http_rewrite_referer_t));
|
||||
if (lcf->referers == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
value = cf->args->elts;
|
||||
server_names = 0;
|
||||
|
||||
for (i = 1; i < cf->args->nelts; i++) {
|
||||
if (value[i].len == 0) {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"invalid referer \"%V\"", &value[i]);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_strcmp(value[i].data, "none") == 0) {
|
||||
lcf->no_referer = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_strcmp(value[i].data, "blocked") == 0) {
|
||||
lcf->blocked_referer = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_strcmp(value[i].data, "server_names") == 0) {
|
||||
server_names = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
ref = ngx_array_push(lcf->referers);
|
||||
if (ref == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (value[i].data[0] != '*') {
|
||||
ref->name = value[i];
|
||||
ref->wildcard = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value[i].data[1] != '.') {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"invalid wildcard referer \"%V\"", &value[i]);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ref->name.len = value[i].len - 1;
|
||||
ref->name.data = value[i].data + 1;
|
||||
ref->wildcard = 1;
|
||||
}
|
||||
|
||||
if (!server_names) {
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
sn = cscf->server_names.elts;
|
||||
for (i = 0; i < cscf->server_names.nelts; i++) {
|
||||
ref = ngx_array_push(lcf->referers);
|
||||
if (ref == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ref->name.len = sn[i].name.len + 1;
|
||||
ref->name.data = ngx_palloc(cf->pool, ref->name.len);
|
||||
if (ref->name.data == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ngx_memcpy(ref->name.data, sn[i].name.data, sn[i].name.len);
|
||||
ref->name.data[sn[i].name.len] = '/';
|
||||
ref->wildcard = sn[i].wildcard;
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
@ -1025,13 +807,10 @@ ngx_http_rewrite_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
ngx_http_rewrite_loc_conf_t *lcf = conf;
|
||||
|
||||
ngx_int_t n, index;
|
||||
ngx_int_t index;
|
||||
ngx_str_t *value;
|
||||
ngx_http_variable_t *v;
|
||||
ngx_http_script_compile_t sc;
|
||||
ngx_http_script_var_code_t *var;
|
||||
ngx_http_script_value_code_t *val;
|
||||
ngx_http_script_complex_value_code_t *complex;
|
||||
|
||||
value = cf->args->elts;
|
||||
|
||||
@ -1059,50 +838,10 @@ ngx_http_rewrite_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
v->data = index;
|
||||
}
|
||||
|
||||
n = ngx_http_script_variables_count(&value[2]);
|
||||
|
||||
if (n == 0) {
|
||||
val = ngx_http_script_start_code(cf->pool, &lcf->codes,
|
||||
sizeof(ngx_http_script_value_code_t));
|
||||
if (val == NULL) {
|
||||
if (ngx_http_rewrite_value(cf, lcf, &value[2]) != NGX_CONF_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
n = ngx_atoi(value[2].data, value[2].len);
|
||||
|
||||
if (n == NGX_ERROR) {
|
||||
n = 0;
|
||||
}
|
||||
|
||||
val->code = ngx_http_script_value_code;
|
||||
val->value = (uintptr_t) n;
|
||||
val->text_len = (uintptr_t) value[2].len;
|
||||
val->text_data = (uintptr_t) value[2].data;
|
||||
|
||||
} else {
|
||||
complex = ngx_http_script_start_code(cf->pool, &lcf->codes,
|
||||
sizeof(ngx_http_script_complex_value_code_t));
|
||||
if (complex == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
complex->code = ngx_http_script_complex_value_code;
|
||||
complex->lengths = NULL;
|
||||
|
||||
ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
|
||||
|
||||
sc.cf = cf;
|
||||
sc.source = &value[2];
|
||||
sc.lengths = &complex->lengths;
|
||||
sc.values = &lcf->codes;
|
||||
sc.variables = n;
|
||||
sc.complete_lengths = 1;
|
||||
|
||||
if (ngx_http_script_compile(&sc) != NGX_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
var = ngx_http_script_start_code(cf->pool, &lcf->codes,
|
||||
sizeof(ngx_http_script_var_code_t));
|
||||
if (var == NULL) {
|
||||
@ -1114,3 +853,61 @@ ngx_http_rewrite_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
ngx_http_rewrite_value(ngx_conf_t *cf, ngx_http_rewrite_loc_conf_t *lcf,
|
||||
ngx_str_t *value)
|
||||
{
|
||||
ngx_int_t n;
|
||||
ngx_http_script_compile_t sc;
|
||||
ngx_http_script_value_code_t *val;
|
||||
ngx_http_script_complex_value_code_t *complex;
|
||||
|
||||
n = ngx_http_script_variables_count(value);
|
||||
|
||||
if (n == 0) {
|
||||
val = ngx_http_script_start_code(cf->pool, &lcf->codes,
|
||||
sizeof(ngx_http_script_value_code_t));
|
||||
if (val == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
n = ngx_atoi(value->data, value->len);
|
||||
|
||||
if (n == NGX_ERROR) {
|
||||
n = 0;
|
||||
}
|
||||
|
||||
val->code = ngx_http_script_value_code;
|
||||
val->value = (uintptr_t) n;
|
||||
val->text_len = (uintptr_t) value->len;
|
||||
val->text_data = (uintptr_t) value->data;
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
complex = ngx_http_script_start_code(cf->pool, &lcf->codes,
|
||||
sizeof(ngx_http_script_complex_value_code_t));
|
||||
if (complex == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
complex->code = ngx_http_script_complex_value_code;
|
||||
complex->lengths = NULL;
|
||||
|
||||
ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
|
||||
|
||||
sc.cf = cf;
|
||||
sc.source = value;
|
||||
sc.lengths = &complex->lengths;
|
||||
sc.values = &lcf->codes;
|
||||
sc.variables = n;
|
||||
sc.complete_lengths = 1;
|
||||
|
||||
if (ngx_http_script_compile(&sc) != NGX_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
@ -331,7 +331,8 @@ ngx_http_ssi_header_filter(ngx_http_request_t *r)
|
||||
conf = ngx_http_get_module_loc_conf(r, ngx_http_ssi_filter_module);
|
||||
|
||||
if (!conf->enable
|
||||
|| r->headers_out.content_type.len == 0)
|
||||
|| r->headers_out.content_type.len == 0
|
||||
|| r->headers_out.content_length_n == 0)
|
||||
{
|
||||
return ngx_http_next_header_filter(r);
|
||||
}
|
||||
@ -381,17 +382,8 @@ found:
|
||||
r->filter_need_in_memory = 1;
|
||||
|
||||
if (r->main == r) {
|
||||
r->headers_out.content_length_n = -1;
|
||||
if (r->headers_out.content_length) {
|
||||
r->headers_out.content_length->hash = 0;
|
||||
r->headers_out.content_length = NULL;
|
||||
}
|
||||
|
||||
r->headers_out.last_modified_time = -1;
|
||||
if (r->headers_out.last_modified) {
|
||||
r->headers_out.last_modified->hash = 0;
|
||||
r->headers_out.last_modified = NULL;
|
||||
}
|
||||
ngx_http_clear_content_length(r);
|
||||
ngx_http_clear_last_modified(r);
|
||||
}
|
||||
|
||||
return ngx_http_next_header_filter(r);
|
||||
|
@ -240,19 +240,10 @@ ngx_http_static_handler(ngx_http_request_t *r)
|
||||
r->headers_out.content_length_n = ngx_file_size(&fi);
|
||||
r->headers_out.last_modified_time = ngx_file_mtime(&fi);
|
||||
|
||||
if (r->headers_out.content_length_n == 0) {
|
||||
r->header_only = 1;
|
||||
}
|
||||
|
||||
if (ngx_http_set_content_type(r) != NGX_OK) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
#if (NGX_SUPPRESS_WARN)
|
||||
b = NULL;
|
||||
#endif
|
||||
|
||||
if (!r->header_only) {
|
||||
/* we need to allocate all before the header would be sent */
|
||||
|
||||
b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
|
||||
@ -266,7 +257,6 @@ ngx_http_static_handler(ngx_http_request_t *r)
|
||||
}
|
||||
|
||||
r->filter_allow_ranges = 1;
|
||||
}
|
||||
|
||||
rc = ngx_http_send_header(r);
|
||||
|
||||
@ -274,17 +264,13 @@ ngx_http_static_handler(ngx_http_request_t *r)
|
||||
return rc;
|
||||
}
|
||||
|
||||
b->in_file = 1;
|
||||
|
||||
if (r->main == r) {
|
||||
b->last_buf = 1;
|
||||
}
|
||||
|
||||
b->last_in_chain = 1;
|
||||
|
||||
b->file_pos = 0;
|
||||
b->file_last = ngx_file_size(&fi);
|
||||
|
||||
b->in_file = b->file_last ? 1: 0;
|
||||
b->last_buf = (r->main == r) ? 1: 0;
|
||||
b->last_in_chain = 1;
|
||||
|
||||
b->file->fd = fd;
|
||||
b->file->name = path;
|
||||
b->file->log = log;
|
||||
|
@ -1,4 +1,9 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) Igor Sysoev
|
||||
*/
|
||||
|
||||
|
||||
#include <ngx_config.h>
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_http.h>
|
||||
|
@ -343,6 +343,14 @@ static ngx_command_t ngx_http_core_commands[] = {
|
||||
0,
|
||||
NULL },
|
||||
|
||||
{ ngx_string("post_action"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
||||
|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_str_slot,
|
||||
NGX_HTTP_LOC_CONF_OFFSET,
|
||||
offsetof(ngx_http_core_loc_conf_t, post_action),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("error_log"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
||||
ngx_http_core_error_log,
|
||||
@ -1105,8 +1113,10 @@ ngx_http_subrequest(ngx_http_request_t *r,
|
||||
sr->headers_in = r->headers_in;
|
||||
|
||||
sr->start_time = ngx_time();
|
||||
sr->headers_out.content_length_n = -1;
|
||||
sr->headers_out.last_modified_time = -1;
|
||||
|
||||
ngx_http_clear_content_length(sr);
|
||||
ngx_http_clear_accept_ranges(sr);
|
||||
ngx_http_clear_last_modified(sr);
|
||||
|
||||
sr->request_body = r->request_body;
|
||||
|
||||
@ -1859,11 +1869,10 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf)
|
||||
/*
|
||||
* set by ngx_pcalloc():
|
||||
*
|
||||
* lcf->root.len = 0;
|
||||
* lcf->root.data = NULL;
|
||||
* lcf->root = { 0, NULL };
|
||||
* lcf->post_action = { 0, NULL };
|
||||
* lcf->types = NULL;
|
||||
* lcf->default_type.len = 0;
|
||||
* lcf->default_type.data = NULL;
|
||||
* lcf->default_type = { 0, NULL };
|
||||
* lcf->err_log = NULL;
|
||||
* lcf->error_pages = NULL;
|
||||
* lcf->client_body_path = NULL;
|
||||
@ -1923,6 +1932,10 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (conf->post_action.data == NULL) {
|
||||
conf->post_action = prev->post_action;
|
||||
}
|
||||
|
||||
if (conf->types == NULL) {
|
||||
if (prev->types) {
|
||||
conf->types = prev->types;
|
||||
|
@ -145,9 +145,9 @@ typedef struct {
|
||||
|
||||
#define ngx_http_server_names_hash_key(key, name, len, prime) \
|
||||
{ \
|
||||
ngx_uint_t n; \
|
||||
for (key = 0, n = 0; n < len; n++) { \
|
||||
key += name[n]; \
|
||||
ngx_uint_t n0; \
|
||||
for (key = 0, n0 = 0; n0 < len; n0++) { \
|
||||
key += name[n0]; \
|
||||
} \
|
||||
key %= prime; \
|
||||
}
|
||||
@ -202,11 +202,12 @@ struct ngx_http_core_loc_conf_s {
|
||||
|
||||
ngx_http_handler_pt handler;
|
||||
|
||||
ngx_str_t root; /* root, alias */
|
||||
|
||||
ngx_array_t *types;
|
||||
ngx_str_t default_type;
|
||||
|
||||
ngx_str_t root; /* root, alias */
|
||||
ngx_str_t post_action;
|
||||
|
||||
size_t client_max_body_size; /* client_max_body_size */
|
||||
size_t client_body_buffer_size; /* client_body_buffer_size */
|
||||
size_t send_lowat; /* send_lowat */
|
||||
@ -245,14 +246,6 @@ struct ngx_http_core_loc_conf_s {
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern ngx_http_module_t ngx_http_core_module_ctx;
|
||||
extern ngx_module_t ngx_http_core_module;
|
||||
|
||||
extern ngx_uint_t ngx_http_max_module;
|
||||
|
||||
|
||||
|
||||
ngx_int_t ngx_http_find_location_config(ngx_http_request_t *r);
|
||||
|
||||
ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r);
|
||||
@ -278,4 +271,35 @@ ngx_int_t ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *chain);
|
||||
ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *chain);
|
||||
|
||||
|
||||
extern ngx_http_module_t ngx_http_core_module_ctx;
|
||||
extern ngx_module_t ngx_http_core_module;
|
||||
|
||||
extern ngx_uint_t ngx_http_max_module;
|
||||
|
||||
|
||||
#define ngx_http_clear_content_length(r) \
|
||||
\
|
||||
r->headers_out.content_length_n = -1; \
|
||||
if (r->headers_out.content_length) { \
|
||||
r->headers_out.content_length->hash = 0; \
|
||||
r->headers_out.content_length = NULL; \
|
||||
}
|
||||
\
|
||||
#define ngx_http_clear_accept_ranges(r) \
|
||||
\
|
||||
r->filter_allow_ranges = 0; \
|
||||
if (r->headers_out.accept_ranges) { \
|
||||
r->headers_out.accept_ranges->hash = 0 ; \
|
||||
r->headers_out.accept_ranges = NULL; \
|
||||
}
|
||||
|
||||
#define ngx_http_clear_last_modified(r) \
|
||||
\
|
||||
r->headers_out.last_modified_time = -1; \
|
||||
if (r->headers_out.last_modified) { \
|
||||
r->headers_out.last_modified->hash = 0; \
|
||||
r->headers_out.last_modified = NULL; \
|
||||
}
|
||||
|
||||
|
||||
#endif /* _NGX_HTTP_CORE_H_INCLUDED_ */
|
||||
|
@ -51,7 +51,6 @@ static u_char *ngx_http_log_error_handler(ngx_http_request_t *r, u_char *buf,
|
||||
#if (NGX_HTTP_SSL)
|
||||
static void ngx_http_ssl_handshake(ngx_event_t *rev);
|
||||
static void ngx_http_ssl_handshake_handler(ngx_connection_t *c);
|
||||
static void ngx_http_ssl_close_handler(ngx_event_t *ev);
|
||||
#endif
|
||||
|
||||
|
||||
@ -1520,6 +1519,13 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
|
||||
return;
|
||||
}
|
||||
|
||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||
|
||||
if (clcf->post_action.data) {
|
||||
ngx_http_internal_redirect(r, &clcf->post_action, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (r->connection->read->timer_set) {
|
||||
ngx_del_timer(r->connection->read);
|
||||
}
|
||||
@ -1539,8 +1545,6 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
|
||||
return;
|
||||
}
|
||||
|
||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||
|
||||
if (!ngx_terminate
|
||||
&& !ngx_exiting
|
||||
&& r->keepalive != 0
|
||||
@ -2248,6 +2252,7 @@ ngx_http_lingering_close_handler(ngx_event_t *rev)
|
||||
"http lingering close handler");
|
||||
|
||||
if (rev->timedout) {
|
||||
c->timedout = 1;
|
||||
ngx_http_close_request(r, 0);
|
||||
return;
|
||||
}
|
||||
@ -2423,8 +2428,7 @@ ngx_http_close_connection(ngx_connection_t *c)
|
||||
|
||||
if (c->ssl) {
|
||||
if (ngx_ssl_shutdown(c) == NGX_AGAIN) {
|
||||
c->read->handler = ngx_http_ssl_close_handler;
|
||||
c->write->handler = ngx_http_ssl_close_handler;
|
||||
c->ssl->handler = ngx_http_close_connection;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2443,27 +2447,6 @@ ngx_http_close_connection(ngx_connection_t *c)
|
||||
}
|
||||
|
||||
|
||||
#if (NGX_HTTP_SSL)
|
||||
|
||||
static void
|
||||
ngx_http_ssl_close_handler(ngx_event_t *ev)
|
||||
{
|
||||
ngx_connection_t *c;
|
||||
|
||||
c = ev->data;
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, "http ssl close handler");
|
||||
|
||||
if (ngx_ssl_shutdown(c) == NGX_AGAIN) {
|
||||
return;
|
||||
}
|
||||
|
||||
ngx_http_close_connection(c);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static u_char *
|
||||
ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len)
|
||||
{
|
||||
|
@ -143,6 +143,7 @@ ngx_http_read_client_request_body_handler(ngx_http_request_t *r)
|
||||
ngx_int_t rc;
|
||||
|
||||
if (r->connection->read->timedout) {
|
||||
r->connection->timedout = 1;
|
||||
ngx_http_finalize_request(r, NGX_HTTP_REQUEST_TIME_OUT);
|
||||
return;
|
||||
}
|
||||
|
@ -664,6 +664,7 @@ ngx_http_script_regex_start_code(ngx_http_script_engine_t *e)
|
||||
void
|
||||
ngx_http_script_regex_end_code(ngx_http_script_engine_t *e)
|
||||
{
|
||||
u_char *dst, *src;
|
||||
ngx_http_request_t *r;
|
||||
ngx_http_script_regex_end_code_t *code;
|
||||
|
||||
@ -678,6 +679,17 @@ ngx_http_script_regex_end_code(ngx_http_script_engine_t *e)
|
||||
|
||||
if (code->redirect) {
|
||||
|
||||
dst = e->buf.data;
|
||||
src = e->buf.data;
|
||||
|
||||
ngx_unescape_uri(&dst, &src, e->pos - e->buf.data);
|
||||
|
||||
if (src < e->pos) {
|
||||
dst = ngx_copy(dst, src, e->pos - src);
|
||||
}
|
||||
|
||||
e->pos = dst;
|
||||
|
||||
if (code->add_args && r->args.len) {
|
||||
*e->pos++ = (u_char) (code->args ? '&' : '?');
|
||||
e->pos = ngx_copy(e->pos, r->args.data, r->args.len);
|
||||
@ -798,12 +810,68 @@ ngx_http_script_if_code(ngx_http_script_engine_t *e)
|
||||
}
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
||||
"http script if false");
|
||||
"http script if: false");
|
||||
|
||||
e->ip += code->next;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ngx_http_script_equal_code(ngx_http_script_engine_t *e)
|
||||
{
|
||||
ngx_http_variable_value_t *val, *res;
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
||||
"http script equal");
|
||||
|
||||
e->sp--;
|
||||
val = e->sp;
|
||||
res = e->sp - 1;
|
||||
|
||||
e->ip += sizeof(uintptr_t);
|
||||
|
||||
if (val->len == res->len && ngx_strncmp(val->data, res->data, res->len)
|
||||
== 0)
|
||||
{
|
||||
*res = ngx_http_variable_true_value;
|
||||
return;
|
||||
}
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
||||
"http script equal: no");
|
||||
|
||||
*res = ngx_http_variable_null_value;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ngx_http_script_not_equal_code(ngx_http_script_engine_t *e)
|
||||
{
|
||||
ngx_http_variable_value_t *val, *res;
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
||||
"http script not equal");
|
||||
|
||||
e->sp--;
|
||||
val = e->sp;
|
||||
res = e->sp - 1;
|
||||
|
||||
e->ip += sizeof(uintptr_t);
|
||||
|
||||
if (val->len == res->len && ngx_strncmp(val->data, res->data, res->len)
|
||||
== 0)
|
||||
{
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
||||
"http script not equal: no");
|
||||
|
||||
*res = ngx_http_variable_null_value;
|
||||
return;
|
||||
}
|
||||
|
||||
*res = ngx_http_variable_true_value;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ngx_http_script_complex_value_code(ngx_http_script_engine_t *e)
|
||||
{
|
||||
@ -840,8 +908,8 @@ ngx_http_script_complex_value_code(ngx_http_script_engine_t *e)
|
||||
|
||||
e->pos = e->buf.data;
|
||||
|
||||
e->sp->data = e->buf.data;
|
||||
e->sp->len = e->buf.len;
|
||||
e->sp->data = e->buf.data;
|
||||
e->sp++;
|
||||
}
|
||||
|
||||
@ -855,11 +923,12 @@ ngx_http_script_value_code(ngx_http_script_engine_t *e)
|
||||
|
||||
e->ip += sizeof(ngx_http_script_value_code_t);
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
||||
"http script value");
|
||||
|
||||
e->sp->len = code->text_len;
|
||||
e->sp->data = (u_char *) code->text_data;
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
||||
"http script value: \"%V\"", e->sp);
|
||||
|
||||
e->sp++;
|
||||
}
|
||||
|
||||
@ -914,8 +983,7 @@ ngx_http_script_var_code(ngx_http_script_engine_t *e)
|
||||
return;
|
||||
}
|
||||
|
||||
e->sp->data = (u_char *) "";
|
||||
e->sp->len = 0;
|
||||
*e->sp = ngx_http_variable_null_value;
|
||||
e->sp++;
|
||||
}
|
||||
|
||||
|
@ -173,6 +173,8 @@ void ngx_http_script_regex_end_code(ngx_http_script_engine_t *e);
|
||||
void ngx_http_script_return_code(ngx_http_script_engine_t *e);
|
||||
void ngx_http_script_break_code(ngx_http_script_engine_t *e);
|
||||
void ngx_http_script_if_code(ngx_http_script_engine_t *e);
|
||||
void ngx_http_script_equal_code(ngx_http_script_engine_t *e);
|
||||
void ngx_http_script_not_equal_code(ngx_http_script_engine_t *e);
|
||||
void ngx_http_script_complex_value_code(ngx_http_script_engine_t *e);
|
||||
void ngx_http_script_value_code(ngx_http_script_engine_t *e);
|
||||
void ngx_http_script_set_var_code(ngx_http_script_engine_t *e);
|
||||
|
@ -371,6 +371,9 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
|
||||
r->headers_out.content_length = NULL;
|
||||
}
|
||||
|
||||
ngx_http_clear_accept_ranges(r);
|
||||
ngx_http_clear_last_modified(r);
|
||||
|
||||
rc = ngx_http_send_header(r);
|
||||
|
||||
if (rc == NGX_ERROR || r->header_only) {
|
||||
|
@ -84,6 +84,12 @@ static ngx_int_t ngx_http_upstream_response_time_variable(ngx_http_request_t *r,
|
||||
static void *ngx_http_upstream_create_main_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf);
|
||||
|
||||
#if (NGX_HTTP_SSL)
|
||||
static void ngx_http_upstream_ssl_handshake(ngx_connection_t *c);
|
||||
static void ngx_http_upstream_ssl_shutdown(ngx_connection_t *c,
|
||||
ngx_peer_t *peer);
|
||||
#endif
|
||||
|
||||
|
||||
ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = {
|
||||
|
||||
@ -147,6 +153,12 @@ ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = {
|
||||
ngx_http_upstream_copy_header_line,
|
||||
offsetof(ngx_http_headers_out_t, expires), 1 },
|
||||
|
||||
{ ngx_string("Accept-Ranges"),
|
||||
ngx_http_upstream_process_header_line,
|
||||
offsetof(ngx_http_upstream_headers_in_t, accept_ranges),
|
||||
ngx_http_upstream_copy_header_line,
|
||||
offsetof(ngx_http_headers_out_t, accept_ranges), 1 },
|
||||
|
||||
{ ngx_string("Connection"),
|
||||
ngx_http_upstream_ignore_header_line, 0,
|
||||
ngx_http_upstream_ignore_header_line, 0, 0 },
|
||||
@ -482,6 +494,7 @@ static void
|
||||
ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
{
|
||||
ngx_int_t rc;
|
||||
ngx_peer_t *peer;
|
||||
ngx_connection_t *c;
|
||||
|
||||
r->connection->log->action = "connecting to upstream";
|
||||
@ -499,7 +512,8 @@ ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
return;
|
||||
}
|
||||
|
||||
u->state->peer = &u->peer.peers->peer[u->peer.cur_peer].name;
|
||||
peer = &u->peer.peers->peer[u->peer.cur_peer];
|
||||
u->state->peer = &peer->name;
|
||||
|
||||
if (rc == NGX_BUSY) {
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "no live upstreams");
|
||||
@ -510,6 +524,8 @@ ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
return;
|
||||
}
|
||||
|
||||
/* rc == NGX_OK || rc == NGX_AGAIN */
|
||||
|
||||
c = u->peer.connection;
|
||||
|
||||
c->data = r;
|
||||
@ -568,10 +584,75 @@ ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
|
||||
/* rc == NGX_OK */
|
||||
|
||||
#if (NGX_HTTP_SSL)
|
||||
|
||||
if (u->conf->ssl) {
|
||||
if (c->ssl == NULL) {
|
||||
|
||||
if (ngx_ssl_create_connection(u->conf->ssl, c,
|
||||
NGX_SSL_BUFFER|NGX_SSL_CLIENT)
|
||||
== NGX_ERROR)
|
||||
{
|
||||
ngx_http_upstream_finalize_request(r, u,
|
||||
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
c->sendfile = 0;
|
||||
}
|
||||
|
||||
if (ngx_ssl_set_session(c, peer->ssl_session) != NGX_OK) {
|
||||
ngx_http_upstream_finalize_request(r, u,
|
||||
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
rc = ngx_ssl_handshake(c);
|
||||
|
||||
if (rc == NGX_AGAIN) {
|
||||
c->ssl->handler = ngx_http_upstream_ssl_handshake;
|
||||
return;
|
||||
}
|
||||
|
||||
ngx_http_upstream_ssl_handshake(c);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ngx_http_upstream_send_request(r, u);
|
||||
}
|
||||
|
||||
|
||||
#if (NGX_HTTP_SSL)
|
||||
|
||||
static void
|
||||
ngx_http_upstream_ssl_handshake(ngx_connection_t *c)
|
||||
{
|
||||
ngx_http_request_t *r;
|
||||
ngx_http_upstream_t *u;
|
||||
|
||||
r = c->data;
|
||||
u = r->upstream;
|
||||
|
||||
if (c->ssl->handshaked) {
|
||||
|
||||
c->write->handler = ngx_http_upstream_send_request_handler;
|
||||
c->read->handler = ngx_http_upstream_process_header;
|
||||
|
||||
ngx_http_upstream_send_request(r, u);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_upstream_reinit(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
{
|
||||
@ -831,7 +912,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
|
||||
#endif
|
||||
}
|
||||
|
||||
n = ngx_recv(u->peer.connection, u->header_in.last,
|
||||
n = u->peer.connection->recv(u->peer.connection, u->header_in.last,
|
||||
u->header_in.end - u->header_in.last);
|
||||
|
||||
if (n == NGX_AGAIN) {
|
||||
@ -1292,6 +1373,7 @@ ngx_http_upstream_process_body(ngx_event_t *ev)
|
||||
|
||||
} else {
|
||||
p->downstream_error = 1;
|
||||
c->timedout = 1;
|
||||
ngx_log_error(NGX_LOG_ERR, c->log, NGX_ETIMEDOUT,
|
||||
"client timed out");
|
||||
}
|
||||
@ -1458,7 +1540,12 @@ ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u,
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"close http upstream connection: %d",
|
||||
u->peer.connection->fd);
|
||||
|
||||
#if (NGX_HTTP_SSL)
|
||||
if (u->peer.connection->ssl) {
|
||||
ngx_http_upstream_ssl_shutdown(u->peer.connection,
|
||||
&u->peer.peers->peer[u->peer.cur_peer]);
|
||||
}
|
||||
#endif
|
||||
ngx_close_connection(u->peer.connection);
|
||||
}
|
||||
|
||||
@ -1508,7 +1595,15 @@ ngx_http_upstream_finalize_request(ngx_http_request_t *r,
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"close http upstream connection: %d",
|
||||
u->peer.connection->fd);
|
||||
#if (NGX_HTTP_SSL)
|
||||
|
||||
/* TODO: do not shutdown persistent connection */
|
||||
|
||||
if (u->peer.connection->ssl) {
|
||||
ngx_http_upstream_ssl_shutdown(u->peer.connection,
|
||||
&u->peer.peers->peer[u->peer.cur_peer]);
|
||||
}
|
||||
#endif
|
||||
ngx_close_connection(u->peer.connection);
|
||||
}
|
||||
|
||||
@ -1549,6 +1644,35 @@ ngx_http_upstream_finalize_request(ngx_http_request_t *r,
|
||||
}
|
||||
|
||||
|
||||
#if (NGX_HTTP_SSL)
|
||||
|
||||
static void
|
||||
ngx_http_upstream_ssl_shutdown(ngx_connection_t *c, ngx_peer_t *peer)
|
||||
{
|
||||
/* lock peer mutex */
|
||||
|
||||
if (peer->ssl_session) {
|
||||
ngx_ssl_free_session(peer->ssl_session);
|
||||
}
|
||||
|
||||
peer->ssl_session = ngx_ssl_get_session(c);
|
||||
|
||||
/* unlock peer mutex */
|
||||
|
||||
/*
|
||||
* We send the "close notify" shutdown alert to the upstream only
|
||||
* and do not wait its "close notify" shutdown alert.
|
||||
* It is acceptable according to the TLS standard.
|
||||
*/
|
||||
|
||||
c->ssl->no_wait_shutdown = 1;
|
||||
|
||||
(void) ngx_ssl_shutdown(c);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_upstream_process_header_line(ngx_http_request_t *r, ngx_table_elt_t *h,
|
||||
ngx_uint_t offset)
|
||||
|
@ -85,6 +85,11 @@ typedef struct {
|
||||
ngx_str_t uri;
|
||||
ngx_str_t location;
|
||||
ngx_str_t url; /* used in proxy_rewrite_location */
|
||||
|
||||
#if (NGX_HTTP_SSL)
|
||||
ngx_ssl_t *ssl;
|
||||
#endif
|
||||
|
||||
} ngx_http_upstream_conf_t;
|
||||
|
||||
|
||||
|
@ -16,8 +16,14 @@ static ngx_int_t ngx_http_variable_header(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data);
|
||||
static ngx_int_t ngx_http_variable_headers(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data);
|
||||
static ngx_int_t ngx_http_variable_unknown_header(ngx_http_request_t *r,
|
||||
|
||||
static ngx_int_t ngx_http_variable_unknown_header_in(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data);
|
||||
static ngx_int_t ngx_http_variable_unknown_header_out(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data);
|
||||
static ngx_int_t ngx_http_variable_unknown_header(ngx_http_variable_value_t *v,
|
||||
ngx_str_t *var, ngx_list_part_t *part, size_t prefix);
|
||||
|
||||
static ngx_int_t ngx_http_variable_host(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data);
|
||||
static ngx_int_t ngx_http_variable_remote_addr(ngx_http_request_t *r,
|
||||
@ -124,6 +130,12 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
|
||||
};
|
||||
|
||||
|
||||
ngx_http_variable_value_t ngx_http_variable_null_value =
|
||||
ngx_http_variable("");
|
||||
ngx_http_variable_value_t ngx_http_variable_true_value =
|
||||
ngx_http_variable("1");
|
||||
|
||||
|
||||
ngx_http_variable_t *
|
||||
ngx_http_add_variable(ngx_conf_t *cf, ngx_str_t *name, ngx_uint_t flags)
|
||||
{
|
||||
@ -324,7 +336,19 @@ ngx_http_get_variable(ngx_http_request_t *r, ngx_str_t *name)
|
||||
|
||||
if (ngx_strncmp(name->data, "http_", 5) == 0) {
|
||||
|
||||
if (ngx_http_variable_unknown_header(r, vv, (uintptr_t) name) == NGX_OK)
|
||||
if (ngx_http_variable_unknown_header_in(r, vv, (uintptr_t) name)
|
||||
== NGX_OK)
|
||||
{
|
||||
return vv;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ngx_strncmp(name->data, "sent_http_", 10) == 0) {
|
||||
|
||||
if (ngx_http_variable_unknown_header_out(r, vv, (uintptr_t) name)
|
||||
== NGX_OK)
|
||||
{
|
||||
return vv;
|
||||
}
|
||||
@ -446,17 +470,33 @@ ngx_http_variable_headers(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_variable_unknown_header(ngx_http_request_t *r,
|
||||
ngx_http_variable_unknown_header_in(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data)
|
||||
{
|
||||
ngx_str_t *var = (ngx_str_t *) data;
|
||||
return ngx_http_variable_unknown_header(v, (ngx_str_t *) data,
|
||||
&r->headers_in.headers.part,
|
||||
sizeof("http_") - 1);
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_variable_unknown_header_out(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data)
|
||||
{
|
||||
return ngx_http_variable_unknown_header(v, (ngx_str_t *) data,
|
||||
&r->headers_out.headers.part,
|
||||
sizeof("sent_http_") - 1);
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_variable_unknown_header(ngx_http_variable_value_t *v, ngx_str_t *var,
|
||||
ngx_list_part_t *part, size_t prefix)
|
||||
{
|
||||
u_char ch;
|
||||
ngx_uint_t i, n;
|
||||
ngx_list_part_t *part;
|
||||
ngx_table_elt_t *header;
|
||||
|
||||
part = &r->headers_in.headers.part;
|
||||
header = part->elts;
|
||||
|
||||
for (i = 0; /* void */ ; i++) {
|
||||
@ -471,7 +511,7 @@ ngx_http_variable_unknown_header(ngx_http_request_t *r,
|
||||
i = 0;
|
||||
}
|
||||
|
||||
for (n = 0; n + 5 < var->len && n < header[i].key.len; n++) {
|
||||
for (n = 0; n + prefix < var->len && n < header[i].key.len; n++) {
|
||||
ch = header[i].key.data[n];
|
||||
|
||||
if (ch >= 'A' && ch <= 'Z') {
|
||||
@ -481,12 +521,12 @@ ngx_http_variable_unknown_header(ngx_http_request_t *r,
|
||||
ch = '_';
|
||||
}
|
||||
|
||||
if (var->data[n + 5] != ch) {
|
||||
if (var->data[n + prefix] != ch) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (n + 5 == var->len) {
|
||||
if (n + prefix == var->len) {
|
||||
v->len = header[i].value.len;
|
||||
v->valid = 1;
|
||||
v->no_cachable = 0;
|
||||
@ -777,7 +817,14 @@ ngx_http_variables_init_vars(ngx_conf_t *cf)
|
||||
}
|
||||
|
||||
if (ngx_strncmp(v[i].name.data, "http_", 5) == 0) {
|
||||
v[i].handler = ngx_http_variable_unknown_header;
|
||||
v[i].handler = ngx_http_variable_unknown_header_in;
|
||||
v[i].data = (uintptr_t) &v[i].name;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_strncmp(v[i].name.data, "sent_http_", 10) == 0) {
|
||||
v[i].handler = ngx_http_variable_unknown_header_out;
|
||||
v[i].data = (uintptr_t) &v[i].name;
|
||||
|
||||
continue;
|
||||
|
@ -64,4 +64,8 @@ ngx_int_t ngx_http_variables_add_core_vars(ngx_conf_t *cf);
|
||||
ngx_int_t ngx_http_variables_init_vars(ngx_conf_t *cf);
|
||||
|
||||
|
||||
extern ngx_http_variable_value_t ngx_http_variable_null_value;
|
||||
extern ngx_http_variable_value_t ngx_http_variable_true_value;
|
||||
|
||||
|
||||
#endif /* _NGX_HTTP_VARIABLES_H_INCLUDED_ */
|
||||
|
@ -17,7 +17,6 @@ static u_char *ngx_imap_log_error(ngx_log_t *log, u_char *buf, size_t len);
|
||||
|
||||
#if (NGX_IMAP_SSL)
|
||||
static void ngx_imap_ssl_handshake_handler(ngx_connection_t *c);
|
||||
static void ngx_imap_ssl_close_handler(ngx_event_t *ev);
|
||||
#endif
|
||||
|
||||
|
||||
@ -181,6 +180,7 @@ ngx_imap_send(ngx_event_t *wev)
|
||||
|
||||
if (wev->timedout) {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
|
||||
c->timedout = 1;
|
||||
ngx_imap_close_connection(c);
|
||||
return;
|
||||
}
|
||||
@ -246,6 +246,7 @@ ngx_imap_init_protocol(ngx_event_t *rev)
|
||||
|
||||
if (rev->timedout) {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
|
||||
c->timedout = 1;
|
||||
ngx_imap_close_connection(c);
|
||||
return;
|
||||
}
|
||||
@ -298,6 +299,7 @@ ngx_imap_auth_state(ngx_event_t *rev)
|
||||
|
||||
if (rev->timedout) {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
|
||||
c->timedout = 1;
|
||||
ngx_imap_close_connection(c);
|
||||
return;
|
||||
}
|
||||
@ -498,6 +500,7 @@ ngx_pop3_auth_state(ngx_event_t *rev)
|
||||
|
||||
if (rev->timedout) {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
|
||||
c->timedout = 1;
|
||||
ngx_imap_close_connection(c);
|
||||
return;
|
||||
}
|
||||
@ -725,8 +728,7 @@ ngx_imap_close_connection(ngx_connection_t *c)
|
||||
|
||||
if (c->ssl) {
|
||||
if (ngx_ssl_shutdown(c) == NGX_AGAIN) {
|
||||
c->read->handler = ngx_imap_ssl_close_handler;
|
||||
c->write->handler = ngx_imap_ssl_close_handler;
|
||||
c->ssl->handler = ngx_imap_close_connection;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -743,27 +745,6 @@ ngx_imap_close_connection(ngx_connection_t *c)
|
||||
}
|
||||
|
||||
|
||||
#if (NGX_IMAP_SSL)
|
||||
|
||||
static void
|
||||
ngx_imap_ssl_close_handler(ngx_event_t *ev)
|
||||
{
|
||||
ngx_connection_t *c;
|
||||
|
||||
c = ev->data;
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, ev->log, 0, "http ssl close handler");
|
||||
|
||||
if (ngx_ssl_shutdown(c) == NGX_AGAIN) {
|
||||
return;
|
||||
}
|
||||
|
||||
ngx_imap_close_connection(c);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static u_char *
|
||||
ngx_imap_log_error(ngx_log_t *log, u_char *buf, size_t len)
|
||||
{
|
||||
|
@ -172,6 +172,7 @@ ngx_imap_proxy_imap_handler(ngx_event_t *rev)
|
||||
if (rev->timedout) {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT,
|
||||
"upstream timed out");
|
||||
c->timedout = 1;
|
||||
ngx_imap_proxy_internal_server_error(s);
|
||||
return;
|
||||
}
|
||||
@ -310,6 +311,7 @@ ngx_imap_proxy_pop3_handler(ngx_event_t *rev)
|
||||
if (rev->timedout) {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT,
|
||||
"upstream timed out");
|
||||
c->timedout = 1;
|
||||
ngx_imap_proxy_internal_server_error(s);
|
||||
return;
|
||||
}
|
||||
@ -501,6 +503,8 @@ ngx_imap_proxy_handler(ngx_event_t *ev)
|
||||
if (c == s->connection) {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT,
|
||||
"client timed out");
|
||||
c->timedout = 1;
|
||||
|
||||
} else {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT,
|
||||
"upstream timed out");
|
||||
|
@ -22,7 +22,8 @@
|
||||
* timeout, aio_cancel(), aio_error()
|
||||
*/
|
||||
|
||||
ssize_t ngx_aio_read(ngx_connection_t *c, u_char *buf, size_t size)
|
||||
ssize_t
|
||||
ngx_aio_read(ngx_connection_t *c, u_char *buf, size_t size)
|
||||
{
|
||||
int n;
|
||||
ngx_event_t *rev;
|
||||
|
@ -10,7 +10,8 @@
|
||||
#include <ngx_aio.h>
|
||||
|
||||
|
||||
ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl)
|
||||
ssize_t
|
||||
ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl)
|
||||
{
|
||||
int n;
|
||||
u_char *buf, *prev;
|
||||
|
@ -22,7 +22,8 @@
|
||||
* timeout, aio_cancel(), aio_error()
|
||||
*/
|
||||
|
||||
ssize_t ngx_aio_write(ngx_connection_t *c, u_char *buf, size_t size)
|
||||
ssize_t
|
||||
ngx_aio_write(ngx_connection_t *c, u_char *buf, size_t size)
|
||||
{
|
||||
int n;
|
||||
ngx_event_t *wev;
|
||||
|
@ -10,8 +10,8 @@
|
||||
#include <ngx_aio.h>
|
||||
|
||||
|
||||
ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in,
|
||||
off_t limit)
|
||||
ngx_chain_t *
|
||||
ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
{
|
||||
u_char *buf, *prev;
|
||||
off_t send, sent;
|
||||
|
@ -58,7 +58,8 @@ ngx_int_t ngx_threads_n;
|
||||
#endif
|
||||
|
||||
|
||||
u_char master_process[] = "master process";
|
||||
u_long cpu_affinity;
|
||||
static u_char master_process[] = "master process";
|
||||
|
||||
|
||||
void
|
||||
@ -312,14 +313,17 @@ ngx_single_process_cycle(ngx_cycle_t *cycle)
|
||||
static void
|
||||
ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
|
||||
{
|
||||
ngx_int_t i;
|
||||
ngx_int_t i, s;
|
||||
ngx_channel_t ch;
|
||||
|
||||
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes");
|
||||
|
||||
ch.command = NGX_CMD_OPEN_CHANNEL;
|
||||
|
||||
while (n--) {
|
||||
for (i = 0; i < n; i++) {
|
||||
|
||||
cpu_affinity = ngx_get_cpu_affinity(i);
|
||||
|
||||
ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
|
||||
"worker process", type);
|
||||
|
||||
@ -327,11 +331,11 @@ ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
|
||||
ch.slot = ngx_process_slot;
|
||||
ch.fd = ngx_processes[ngx_process_slot].channel[0];
|
||||
|
||||
for (i = 0; i < ngx_last_process; i++) {
|
||||
for (s = 0; s < ngx_last_process; s++) {
|
||||
|
||||
if (i == ngx_process_slot
|
||||
|| ngx_processes[i].pid == -1
|
||||
|| ngx_processes[i].channel[0] == -1)
|
||||
if (s == ngx_process_slot
|
||||
|| ngx_processes[s].pid == -1
|
||||
|| ngx_processes[s].channel[0] == -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -339,12 +343,12 @@ ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
|
||||
ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
||||
"pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d",
|
||||
ch.slot, ch.pid, ch.fd,
|
||||
i, ngx_processes[i].pid,
|
||||
ngx_processes[i].channel[0]);
|
||||
s, ngx_processes[s].pid,
|
||||
ngx_processes[s].channel[0]);
|
||||
|
||||
/* TODO: NGX_AGAIN */
|
||||
|
||||
ngx_write_channel(ngx_processes[i].channel[0],
|
||||
ngx_write_channel(ngx_processes[s].channel[0],
|
||||
&ch, sizeof(ngx_channel_t), cycle->log);
|
||||
}
|
||||
}
|
||||
@ -817,6 +821,20 @@ ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
|
||||
}
|
||||
}
|
||||
|
||||
#if (NGX_HAVE_SCHED_SETAFFINITY)
|
||||
|
||||
if (cpu_affinity) {
|
||||
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
|
||||
"sched_setaffinity(0x%08Xl)", cpu_affinity);
|
||||
|
||||
if (sched_setaffinity(0, 32, (cpu_set_t *) &cpu_affinity) == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||
"sched_setaffinity(0x%08Xl) failed", cpu_affinity);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if (NGX_HAVE_PR_SET_DUMPABLE)
|
||||
|
||||
/* allow coredump after setuid() in Linux 2.4.x */
|
||||
|
Loading…
Reference in New Issue
Block a user