atom feed11 messages in ru.sysoev.nginxRe: rewrite for javascript files.. ag...
FromSent OnAttachments
Chris CorteseMar 10, 2009 11:29 am 
Igor SysoevMar 10, 2009 11:41 am 
Chris CorteseMar 10, 2009 1:39 pm 
Chris CorteseMar 10, 2009 6:31 pm 
Anıl ÇetinMar 10, 2009 9:05 pm 
Glen LumanauMar 10, 2009 10:01 pm 
MaxMar 12, 2009 12:52 am 
Chris ZimmermanMar 12, 2009 2:39 am 
Chris ZimmermanMar 12, 2009 2:44 am 
JoeMar 13, 2009 1:33 pm 
Anıl ÇetinMar 13, 2009 4:59 pm 
Subject:Re: rewrite for javascript files.. again, fire on live site
From:Chris Cortese (cort@gmail.com)
Date:Mar 10, 2009 6:31:50 pm
List:ru.sysoev.nginx

I finally got this working but I had to go back to a rewrite method.

The relevant part of the config is:

location ~ /javascript/(.*\.js) { rewrite /javascript/(.*\.js) /combine.php?type=javascript&files=$1 last; }

(and similarly for css)

I'm not sure why I couldn't get the non-rewrite method working. I am not really clear on how QUERY_STRING works. For 99% of the php (the code igniter part), setting the QUERY_STRING q=$request_uri does it (in the CodeIgniter config you have to set the protocol to REQUEST_URI). like so:

location / { fastcgi_pass 127.0.0.1:10005; fastcgi_param SCRIPT_FILENAME /home/fugbert/www/live/escort-space/trunk/html/public/index.php; fastcgi_param QUERY_STRING q=$request_uri; include /usr/local/nginx/conf/fastcgi_params; }

combine.php doesn't work the way CodeIgniter does. It's just a PHP script that expects (for example) ?type=javascript&files=fileA.js,fileB.js,fileC.js

Chris

Igor Sysoev wrote:

On Tue, Mar 10, 2009 at 11:29:42AM -0700, Chris Cortese wrote:

Hello,

Somehow my rewrite for Javascript got broken again. I've tried every possible combination of things I can think of. What I need is:

orig URL: http://mysite.com/javascript/fileA.js,fileB.js,fileC.js

...becomes...

dest URL: http://mysite.com/combine.php?type=javascript&files=fileAjs.,fileB.js,fileC.js

So this is the latest variation I've tried, with the new nginx 0.7.40:

location ^/javascript/(.*)$ { fastcgi_pass 127.0.0.1:10005; fastcgi_param SCRIPT_FILENAME /home/fugbert/www/live/escort-space/trunk/html/public/combine.php?type=javascript&files=$1; fastcgi_param QUERY_STRING q=$request_uri; include /etc/nginx/fastcgi_params; }

** in fastcgi_params, I have the defaults except I commented out QUERY_STRING line.

It's really strange: in my debug log I see

2009/03/10 21:35:31 [debug] 10047#0: *1 http request line: "GET
/javascript/fileA.js,fileB.js,fileC.js HTTP/1.0" 2009/03/10 21:35:31 [debug] 10047#0: *1 http uri:
"/javascript/fileA.js,fileB.js,fileC.js"

[...]

2009/03/10 21:35:31 [debug] 10047#0: *1 http script copy: "SCRIPT_FILENAME" 2009/03/10 21:35:31 [debug] 10047#0: *1 http script copy:
"/home/fugbert/www/live/escort-space/trunk/html/public/combine.php?type=javascript&files=" 2009/03/10 21:35:31 [debug] 10047#0: *1 http script capture:
"fileA.js,fileB.js,fileC.js" 2009/03/10 21:35:31 [debug] 10047#0: *1 fastcgi param: "SCRIPT_FILENAME:
/home/fugbert/www/live/escort-space/trunk/html/public/combine.php?type=javascript&files=fileA.js,fileB.js,fileC.js"

I.e., SCRIPT_FILENAME is right.

The error I'm getting is undefined index "type" which tells me that the $_GET array is not available to combine.php.

This is hurting a live site.

Thanks in advance for your help, Chris