Q: about try_files and regex location

Aleksandar Lazic al-nginx at none.at
Fri Nov 11 12:16:25 UTC 2011


Dear all,

please can you help me to fix the issue with try_files an regex 
location, thank you.

I use

###
sbin/nginx -V
nginx: nginx version: nginx/1.1.4
nginx: built by gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
nginx: TLS SNI support enabled
nginx: configure arguments: --with-debug --with-libatomic 
--without-http_ssi_module --without-http_uwsgi_module 
--without-http_scgi_module --without-http_memcached_module 
--with-http_ssl_module --user=nginx --group=nginx --prefix=server/nginx 
--with-http_stub_status_module
###

with the following config.

###
http {
   server {
...
         location ~ ^/(share|alfresco)(/res)?(.*$)  {
           alias /home/alfresco/alfresco-4.0.b/tomcat/webapps;
           try_files $uri /$1$2 /$1$3 @alfresco;
         }

         location @alfresco {
           proxy_pass   http://alfresco;
         }
   }
}
###

I get the following error:

###
2011/11/11 12:58:09 [error] 5618#0: *33782 open()
"/home/alfresco/alfresco-4.0.b/tomcat/webapps/share/components/document-details/document-link/home/al" 
failed (2: No such file or directory), client: xxx, server: xxx,
request: "GET /share/components/document-details/document-links-min.js 
HTTP/1.1", host: "xxx", referrer: 
"https://xxx/share/page/site/aleks-glossar/document-details?nodeRef=workspace://SpacesStore/985297e8-ff1b-4423-b6e9-8dacc0011196"
###

Could it be that try_files match on '/$1$2' but the open call get 
'/$1$3' or something else?

attached the debug log.

BR
Aleks

#### debug
2011/11/11 12:58:09 [debug] 5618#0: *33782 posix_memalign: 
000000000CD7D350:4096 @16
2011/11/11 12:58:09 [debug] 5618#0: *33782 http process request line
2011/11/11 12:58:09 [debug] 5618#0: *33782 http request line: "GET 
/share/components/document-details/document-links-min.js HTTP/1.1"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http uri: 
"/share/components/document-details/document-links-min.js"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http args: ""
2011/11/11 12:58:09 [debug] 5618#0: *33782 http exten: "js"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http process request header 
line
2011/11/11 12:58:09 [debug] 5618#0: *33782 http header: "Host: XXXX"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http header: "User-Agent: 
Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http header: "Accept: */*"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http header: 
"Accept-Language: de-de,de;q=0.8,en;q=0.5,en-us;q=0.3"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http header: 
"Accept-Encoding: gzip, deflate"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http header: 
"Accept-Charset: UTF-8,*"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http header: "DNT: 1"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http header: "Referer: 
https://xxx/share/page/site/aleks-glossar/document-details?nodeRef=workspace://SpacesStore/985297e8-ff1b-4423-b6e9-8dacc0011196"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http header: "Cookie: 
JSESSIONID=C3A5E3E0985A055C732E884981544337; alfLogin=1321012572; 
alfUsername2="YWxyaXQ=""
2011/11/11 12:58:09 [debug] 5618#0: *33782 http header: "Connection: 
keep-alive"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http header done
2011/11/11 12:58:09 [debug] 5618#0: *33782 event timer del: 7: 
1321012754907
2011/11/11 12:58:09 [debug] 5618#0: *33782 rewrite phase: 0
2011/11/11 12:58:09 [debug] 5618#0: *33782 test location: "/redmine"
2011/11/11 12:58:09 [debug] 5618#0: *33782 test location: ~ 
"^/(share|alfresco)(/res)?(.*$)"
2011/11/11 12:58:09 [debug] 5618#0: *33782 using configuration 
"^/(share|alfresco)(/res)?(.*$)"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http cl:-1 max:52428800
2011/11/11 12:58:09 [debug] 5618#0: *33782 rewrite phase: 2
2011/11/11 12:58:09 [debug] 5618#0: *33782 post rewrite phase: 3
2011/11/11 12:58:09 [debug] 5618#0: *33782 generic phase: 4
2011/11/11 12:58:09 [debug] 5618#0: *33782 generic phase: 5
2011/11/11 12:58:09 [debug] 5618#0: *33782 access phase: 6
2011/11/11 12:58:09 [debug] 5618#0: *33782 access phase: 7
2011/11/11 12:58:09 [debug] 5618#0: *33782 post access phase: 8
2011/11/11 12:58:09 [debug] 5618#0: *33782 try files phase: 9
2011/11/11 12:58:09 [debug] 5618#0: *33782 http script copy: 
"/home/alfresco/alfresco-4.0.b/tomcat/webapps"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http script var: 
"/share/components/document-details/document-links-min.js"




2011/11/11 12:58:09 [debug] 5618#0: *33782 trying to use file: 
"/share/components/document-details/document-links-min.js" 
"/home/alfresco/alfresco-4.0.b/tomcat/webapps/share/components/document-details/document-links-min.js"



2011/11/11 12:58:09 [debug] 5618#0: *33782 try file uri: 
"/share/components/document-details/document-links-min.js"
2011/11/11 12:58:09 [debug] 5618#0: *33782 content phase: 10
2011/11/11 12:58:09 [debug] 5618#0: *33782 content phase: 11
2011/11/11 12:58:09 [debug] 5618#0: *33782 content phase: 12
2011/11/11 12:58:09 [debug] 5618#0: *33782 http script copy: 
"/home/alfresco/alfresco-4.0.b/tomcat/webapps"


2011/11/11 12:58:09 [debug] 5618#0: *33782 http filename: 
"/home/alfresco/alfresco-4.0.b/tomcat/webapps/share/components/document-details/document-link/home/al"


2011/11/11 12:58:09 [debug] 5618#0: *33782 add cleanup: 
000000000CD7DF38
2011/11/11 12:58:09 [error] 5618#0: *33782 open() 
"/home/alfresco/alfresco-4.0.b/tomcat/webapps/share/components/document-details/document-link/home/al" 
failed (2: No such file or directory), client: xxx, server: xxx, 
request: "GET /share/components/document-details/document-links-min.js 
HTTP/1.1", host: "xxx", referrer: 
"https://external.none.at/share/page/site/aleks-glossar/document-details?nodeRef=workspace://SpacesStore/985297e8-ff1b-4423-b6e9-8dacc0011196"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http finalize request: 404, 
"/share/components/document-details/document-link/home/al?" a:1, c:1
2011/11/11 12:58:09 [debug] 5618#0: *33782 http special response: 404, 
"/share/components/document-details/document-link/home/al?"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http set discard body
2011/11/11 12:58:09 [debug] 5618#0: *33782 HTTP/1.1 404 Not Found
Server: nginx/1.1.4
Date: Fri, 11 Nov 2011 11:58:09 GMT
Content-Type: text/html
Content-Length: 168
Connection: keep-alive

2011/11/11 12:58:09 [debug] 5618#0: *33782 write new buf t:1 f:0 
000000000CD7DFB8, pos 000000000CD7DFB8, size: 154 file: 0, size: 0
2011/11/11 12:58:09 [debug] 5618#0: *33782 http write filter: l:0 f:0 
s:154
2011/11/11 12:58:09 [debug] 5618#0: *33782 http output filter 
"/share/components/document-details/document-link/home/al?"
2011/11/11 12:58:09 [debug] 5618#0: *33782 http copy filter: 
"/share/components/document-details/document-link/home/al?"
2011/11/11 12:58:09 [debug] 5618#0: *33782 write old buf t:1 f:0 
000000000CD7DFB8, pos 000000000CD7DFB8, size: 154 file: 0, size: 0
2011/11/11 12:58:09 [debug] 5618#0: *33782 write new buf t:0 f:0 
0000000000000000, pos 00000000006802C0, size: 116 file: 0, size: 0
####



More information about the nginx mailing list