[nginx] Fixed clcf->auto_redirect in uwsgi_pass/scgi_pass with v...

Maxim Dounin mdounin at mdounin.ru
Tue Mar 10 01:07:24 UTC 2026


details:   http://freenginx.org/hg/nginx/rev/6ea8697c0740
branches:  
changeset: 9474:6ea8697c0740
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Tue Mar 10 03:50:52 2026 +0300
description:
Fixed clcf->auto_redirect in uwsgi_pass/scgi_pass with variables.

Previously, clcf->auto_redirect was only set (for locations ending with "/")
when uwsgi_pass and scgi_pass were used without variables, but not with
variables.

For proxy_pass and fastcgi_pass this was fixed in 2989:dff9764eaca2 (0.8.7).
It was not, however, fixed in ngx_http_uwsgi_module (as imported later,
in 3541:21452748d165, 0.8.40) and ngx_http_scgi_module (introduced shortly
after, in 3637:d656caa72ec9, 0.8.42).

The fix is mostly identical to the one in 2989:dff9764eaca2 (0.8.7) and
ensures that clcf->auto_redirect is set both with and without variables.

diffstat:

 src/http/modules/ngx_http_scgi_module.c  |  9 +++++----
 src/http/modules/ngx_http_uwsgi_module.c |  9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diffs (56 lines):

diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c
--- a/src/http/modules/ngx_http_scgi_module.c
+++ b/src/http/modules/ngx_http_scgi_module.c
@@ -1921,8 +1921,13 @@ ngx_http_scgi_pass(ngx_conf_t *cf, ngx_c
     }
 
     clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
+
     clcf->handler = ngx_http_scgi_handler;
 
+    if (clcf->name.len && clcf->name.data[clcf->name.len - 1] == '/') {
+        clcf->auto_redirect = 1;
+    }
+
     value = cf->args->elts;
 
     url = &value[1];
@@ -1958,10 +1963,6 @@ ngx_http_scgi_pass(ngx_conf_t *cf, ngx_c
         return NGX_CONF_ERROR;
     }
 
-    if (clcf->name.len && clcf->name.data[clcf->name.len - 1] == '/') {
-        clcf->auto_redirect = 1;
-    }
-
     return NGX_CONF_OK;
 }
 
diff --git a/src/http/modules/ngx_http_uwsgi_module.c b/src/http/modules/ngx_http_uwsgi_module.c
--- a/src/http/modules/ngx_http_uwsgi_module.c
+++ b/src/http/modules/ngx_http_uwsgi_module.c
@@ -2221,8 +2221,13 @@ ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_
     }
 
     clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
+
     clcf->handler = ngx_http_uwsgi_handler;
 
+    if (clcf->name.len && clcf->name.data[clcf->name.len - 1] == '/') {
+        clcf->auto_redirect = 1;
+    }
+
     value = cf->args->elts;
 
     url = &value[1];
@@ -2281,10 +2286,6 @@ ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_
         return NGX_CONF_ERROR;
     }
 
-    if (clcf->name.len && clcf->name.data[clcf->name.len - 1] == '/') {
-        clcf->auto_redirect = 1;
-    }
-
     return NGX_CONF_OK;
 }
 


More information about the nginx-devel mailing list