Another auth/location question - probably very simple to fix :)

Igor Sysoev is at rambler-co.ru
Sun Aug 17 21:35:39 MSD 2008


On Sun, Aug 17, 2008 at 07:29:43PM +0200, Mikel Arteta wrote:

> Mikel Arteta wrote:
> > This works with version 0.7.10, With the same configuration.
> > 
> > Do you know why ?
> Indeed not.
> 
> With this:
> 
> location    /postfixadmin/admin {
>     auth_basic            "Restricted";
>     auth_basic_user_file  /usr/local/nginx/conf/htpasswd;
> 
>  location ~ \.php$ {
>     fastcgi_pass   localhost:9000;
>     fastcgi_param  SCRIPT_FILENAME 
> /data/www/postfixadmin/admin$fastcgi_script_name;}}
> 
> 
> It works, but just for url "http://domain.fr/postfixadmin/admin" if you 
> put "/ postfixadmin/admin/list-admin.php", more word passes, which is 
> normal with this configuration.
> 
> avec: location  ^~  /postfixadmin/admin {
> => http://img205.imageshack.us/img205/963/adminky5.png

This is bug in 0.7.x - it does not pass request to fastcgi in this
configuration, so you do not see reset connection.
The attached patch fixes the bug.

BTW, what is "avec" - in/with ?


-- 
Igor Sysoev
http://sysoev.ru/en/
-------------- next part --------------
Index: src/http/ngx_http_core_module.c
===================================================================
--- src/http/ngx_http_core_module.c	(revision 1500)
+++ src/http/ngx_http_core_module.c	(working copy)
@@ -1117,18 +1117,41 @@
 }
 
 
+/*
+ * NGX_OK                         - exact or regex match
+ * NGX_DONE                       - auto redirect
+ * NGX_AGAIN                      - inclusive match
+ * NGX_DECLINED                   - no match
+ * NGX_HTTP_INTERNAL_SERVER_ERROR - error
+ */
+
 static ngx_int_t
 ngx_http_core_find_location(ngx_http_request_t *r)
 {
     ngx_int_t                  rc;
     ngx_http_core_loc_conf_t  *pclcf;
+#if (NGX_PCRE)
+    ngx_int_t                  n;
+    ngx_uint_t                 noregex;
+    ngx_http_core_loc_conf_t  *clcf, **clcfp;
 
+    noregex = 0;
+#endif
+
     pclcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
     rc = ngx_http_core_find_static_location(r, pclcf->static_locations);
 
     if (rc == NGX_AGAIN) {
+
+#if (NGX_PCRE)
+        clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+
+        noregex = clcf->noregex;
+#endif
+
         /* look up nested locations */
+
         rc = ngx_http_core_find_location(r);
     }
 
@@ -1139,14 +1162,9 @@
     /* rc == NGX_DECLINED or rc == NGX_AGAIN in nested location */
 
 #if (NGX_PCRE)
-    {
-    ngx_int_t                  n;
-    ngx_http_core_loc_conf_t  *clcf, **clcfp;
 
-    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+    if (noregex == 0 && pclcf->regex_locations) {
 
-    if (clcf->noregex == 0 && pclcf->regex_locations) {
-
         for (clcfp = pclcf->regex_locations; *clcfp; clcfp++) {
 
             ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -1172,10 +1190,11 @@
 
             /* look up nested locations */
 
-            return ngx_http_core_find_location(r);
+            (void) ngx_http_core_find_location(r);
+
+            return NGX_OK;
         }
     }
-    }
 #endif
 
     return rc;


More information about the nginx mailing list