Mercurial > hg > nginx
comparison src/http/modules/ngx_http_proxy_module.c @ 7714:8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
The "false" parameter of the proxy_redirect directive is deprecated.
Warning has been emitted since c2230102df6f (0.7.54).
The "off" parameter of the proxy_redirect, proxy_cookie_domain, and
proxy_cookie_path directives tells nginx not to inherit the
configuration from the previous configuration level.
Previously, after specifying the directive with the "off" parameter,
any other directives were ignored, and syntax checking was disabled.
The syntax was enforced to allow either one directive with the "off"
parameter, or several directives with other parameters.
Also, specifying "proxy_redirect default foo" no longer works like
"proxy_redirect default".
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Sun, 27 Sep 2020 23:21:09 +0300 |
parents | a786e491d08d |
children | 5c7917292b29 |
comparison
equal
deleted
inserted
replaced
7713:45e9281c6c5b | 7714:8dbc9ee97998 |
---|---|
3764 ngx_str_t *value; | 3764 ngx_str_t *value; |
3765 ngx_http_proxy_rewrite_t *pr; | 3765 ngx_http_proxy_rewrite_t *pr; |
3766 ngx_http_compile_complex_value_t ccv; | 3766 ngx_http_compile_complex_value_t ccv; |
3767 | 3767 |
3768 if (plcf->redirect == 0) { | 3768 if (plcf->redirect == 0) { |
3769 return NGX_CONF_OK; | 3769 return "is duplicate"; |
3770 } | 3770 } |
3771 | 3771 |
3772 plcf->redirect = 1; | 3772 plcf->redirect = 1; |
3773 | 3773 |
3774 value = cf->args->elts; | 3774 value = cf->args->elts; |
3775 | 3775 |
3776 if (cf->args->nelts == 2) { | 3776 if (cf->args->nelts == 2) { |
3777 if (ngx_strcmp(value[1].data, "off") == 0) { | 3777 if (ngx_strcmp(value[1].data, "off") == 0) { |
3778 | |
3779 if (plcf->redirects) { | |
3780 return "is duplicate"; | |
3781 } | |
3782 | |
3778 plcf->redirect = 0; | 3783 plcf->redirect = 0; |
3779 plcf->redirects = NULL; | |
3780 return NGX_CONF_OK; | |
3781 } | |
3782 | |
3783 if (ngx_strcmp(value[1].data, "false") == 0) { | |
3784 ngx_conf_log_error(NGX_LOG_ERR, cf, 0, | |
3785 "invalid parameter \"false\", use \"off\" instead"); | |
3786 plcf->redirect = 0; | |
3787 plcf->redirects = NULL; | |
3788 return NGX_CONF_OK; | 3784 return NGX_CONF_OK; |
3789 } | 3785 } |
3790 | 3786 |
3791 if (ngx_strcmp(value[1].data, "default") != 0) { | 3787 if (ngx_strcmp(value[1].data, "default") != 0) { |
3792 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 3788 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3806 pr = ngx_array_push(plcf->redirects); | 3802 pr = ngx_array_push(plcf->redirects); |
3807 if (pr == NULL) { | 3803 if (pr == NULL) { |
3808 return NGX_CONF_ERROR; | 3804 return NGX_CONF_ERROR; |
3809 } | 3805 } |
3810 | 3806 |
3811 if (ngx_strcmp(value[1].data, "default") == 0) { | 3807 if (cf->args->nelts == 2 |
3808 && ngx_strcmp(value[1].data, "default") == 0) | |
3809 { | |
3812 if (plcf->proxy_lengths) { | 3810 if (plcf->proxy_lengths) { |
3813 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 3811 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3814 "\"proxy_redirect default\" cannot be used " | 3812 "\"proxy_redirect default\" cannot be used " |
3815 "with \"proxy_pass\" directive with variables"); | 3813 "with \"proxy_pass\" directive with variables"); |
3816 return NGX_CONF_ERROR; | 3814 return NGX_CONF_ERROR; |
3909 ngx_str_t *value; | 3907 ngx_str_t *value; |
3910 ngx_http_proxy_rewrite_t *pr; | 3908 ngx_http_proxy_rewrite_t *pr; |
3911 ngx_http_compile_complex_value_t ccv; | 3909 ngx_http_compile_complex_value_t ccv; |
3912 | 3910 |
3913 if (plcf->cookie_domains == NULL) { | 3911 if (plcf->cookie_domains == NULL) { |
3914 return NGX_CONF_OK; | 3912 return "is duplicate"; |
3915 } | 3913 } |
3916 | 3914 |
3917 value = cf->args->elts; | 3915 value = cf->args->elts; |
3918 | 3916 |
3919 if (cf->args->nelts == 2) { | 3917 if (cf->args->nelts == 2) { |
3920 | 3918 |
3921 if (ngx_strcmp(value[1].data, "off") == 0) { | 3919 if (ngx_strcmp(value[1].data, "off") == 0) { |
3920 | |
3921 if (plcf->cookie_domains != NGX_CONF_UNSET_PTR) { | |
3922 return "is duplicate"; | |
3923 } | |
3924 | |
3922 plcf->cookie_domains = NULL; | 3925 plcf->cookie_domains = NULL; |
3923 return NGX_CONF_OK; | 3926 return NGX_CONF_OK; |
3924 } | 3927 } |
3925 | 3928 |
3926 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 3929 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3996 ngx_str_t *value; | 3999 ngx_str_t *value; |
3997 ngx_http_proxy_rewrite_t *pr; | 4000 ngx_http_proxy_rewrite_t *pr; |
3998 ngx_http_compile_complex_value_t ccv; | 4001 ngx_http_compile_complex_value_t ccv; |
3999 | 4002 |
4000 if (plcf->cookie_paths == NULL) { | 4003 if (plcf->cookie_paths == NULL) { |
4001 return NGX_CONF_OK; | 4004 return "is duplicate"; |
4002 } | 4005 } |
4003 | 4006 |
4004 value = cf->args->elts; | 4007 value = cf->args->elts; |
4005 | 4008 |
4006 if (cf->args->nelts == 2) { | 4009 if (cf->args->nelts == 2) { |
4007 | 4010 |
4008 if (ngx_strcmp(value[1].data, "off") == 0) { | 4011 if (ngx_strcmp(value[1].data, "off") == 0) { |
4012 | |
4013 if (plcf->cookie_paths != NGX_CONF_UNSET_PTR) { | |
4014 return "is duplicate"; | |
4015 } | |
4016 | |
4009 plcf->cookie_paths = NULL; | 4017 plcf->cookie_paths = NULL; |
4010 return NGX_CONF_OK; | 4018 return NGX_CONF_OK; |
4011 } | 4019 } |
4012 | 4020 |
4013 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 4021 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |