summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_core_module.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2016-12-21 23:10:51 +0300
committerRuslan Ermilov <ru@nginx.com>2016-12-21 23:10:51 +0300
commitdd70e741970c841a1555911f6468b39870c0607b (patch)
treeeaefda6b80598c554414e6b147e93c6ecdbf31c5 /src/http/ngx_http_core_module.c
parentd1f524d0b3e013f23bb9456aa4f2c35916934c27 (diff)
downloadnginx-dd70e741970c841a1555911f6468b39870c0607b.tar.gz
nginx-dd70e741970c841a1555911f6468b39870c0607b.tar.bz2
Core: relative redirects (closes #1000).
The current version of HTTP/1.1 standard allows relative references in redirects (https://tools.ietf.org/html/rfc7231#section-7.1.2). Allow this form for redirects generated by nginx by introducing the new directive absolute_redirect.
Diffstat (limited to 'src/http/ngx_http_core_module.c')
-rw-r--r--src/http/ngx_http_core_module.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 4e37cec26..685e72e4c 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -542,6 +542,13 @@ static ngx_command_t ngx_http_core_commands[] = {
offsetof(ngx_http_core_loc_conf_t, reset_timedout_connection),
NULL },
+ { ngx_string("absolute_redirect"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_core_loc_conf_t, absolute_redirect),
+ NULL },
+
{ ngx_string("server_name_in_redirect"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
@@ -3563,6 +3570,7 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf)
clcf->lingering_timeout = NGX_CONF_UNSET_MSEC;
clcf->resolver_timeout = NGX_CONF_UNSET_MSEC;
clcf->reset_timedout_connection = NGX_CONF_UNSET;
+ clcf->absolute_redirect = NGX_CONF_UNSET;
clcf->server_name_in_redirect = NGX_CONF_UNSET;
clcf->port_in_redirect = NGX_CONF_UNSET;
clcf->msie_padding = NGX_CONF_UNSET;
@@ -3825,6 +3833,8 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_value(conf->reset_timedout_connection,
prev->reset_timedout_connection, 0);
+ ngx_conf_merge_value(conf->absolute_redirect,
+ prev->absolute_redirect, 1);
ngx_conf_merge_value(conf->server_name_in_redirect,
prev->server_name_in_redirect, 0);
ngx_conf_merge_value(conf->port_in_redirect, prev->port_in_redirect, 1);