rewrite for javascript files.. again, fire on live site
Chris Cortese
cortese.consulting at gmail.com
Tue Mar 10 23:39:57 MSK 2009
I tried going back to what I had previously posted here that worked, at
least for the location /javascript/ part. Now it gives me 503 error.
Here's my config:
my_domain.conf:
server {
listen 80;
server_name my_domain.com;
access_log /var/log/nginx/my_domain.access.log;
error_log /var/log/nginx/my_domain.error.log debug;
root /home/my_linux_user/www/live/my_domain/trunk/html/public;
index index.php;
location / {
fastcgi_pass 127.0.0.1:10005;
fastcgi_param SCRIPT_FILENAME
/home/my_linux_user/www/live/my_domain/trunk/html/public/index.php;
fastcgi_param QUERY_STRING q=$request_uri;
include /etc/nginx/fastcgi_params;
}
location /javascript/ {
# fastcgi_pass 127.0.0.1:10005;
# fastcgi_param SCRIPT_FILENAME
/home/my_linux_user/www/live/my_domain/trunk/html/public/combine.php?type=javascript&files=$request_filename;
# fastcgi_param QUERY_STRING $query_string;
# include /etc/nginx/fastcgi_params;
rewrite ^/javascript/(.*)$ /combine.php?type=javascript&files=$1 last;
}
location ^~ /style/ {
fastcgi_pass 127.0.0.1:10005;
fastcgi_param SCRIPT_FILENAME
/home/my_linux_user/www/live/my_domain/trunk/html/public/combine.php?type=css&files=$request_filename;
fastcgi_param QUERY_STRING q=$request_uri;
include /etc/nginx/fastcgi_params;
expires 30d;
access_log off;
}
location /tmp/ {
}
location /filestore/ {
}
location /images/ {
expires 30d;
access_log off;
}
location /cgi-bin/ {
root /home/my_linux_user/www/live/my_domain/trunk;
fastcgi_pass unix:/tmp/cgi.sock;
include /etc/nginx/perl_fcgiwrap_params;
}
location ~* (jpg|jpeg|gif|png)$ {
expires 30d;
access_log off;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:10005;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
/home/my_linux_user/www/live/my_domain/trunk/html/public$fastcgi_script_name;
# fastcgi_param SCRIPT_FILENAME
/home/my_linux_user/www/live/my_domain/trunk/html/public/index.php;
fastcgi_param QUERY_STRING q=$request_uri;
include /etc/nginx/fastcgi_params;
}
location = /style/main_style.php {
fastcgi_pass 127.0.0.1:10005;
fastcgi_param SCRIPT_FILENAME
/home/my_linux_user/www/live/my_domain/trunk/html/public/style/main_style.php;
fastcgi_param QUERY_STRING q=$request_uri;
include /etc/nginx/fastcgi_params;
fastcgi_param QUERY_STRING q=$request_uri;
include /etc/nginx/fastcgi_params;
}
}
nginx.conf:
user nginx;
worker_processes 2;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
#----------------------------------------------------------------------
# Events Module
#
# http://wiki.codemongers.com/NginxEventsModule
#
#----------------------------------------------------------------------
events {
worker_connections 1024;
}http {
include /etc/nginx/mime.types;
error_log /var/log/nginx/error.log;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 2;
gzip on;
gzip_comp_level 6;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
}
fastcgi_params:
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
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
>>
>
>
>
More information about the nginx
mailing list