[Nginx] perl module get an empty body
darkweaver871
nginx-forum at nginx.us
Fri Aug 10 10:03:14 UTC 2012
Hi all,
I'm using Nginx as a reverse proxy and I use Nginx perl module to
inspect my requests and redirect to a different upstream.
It works well but some of request_body are empty and others just make
nginx timeout.
Here is my nginx.conf:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json
application/x-javascript text/xml application/xml application/xml+rss
text/javascript;
##
# Virtual Host Configs
##
perl_modules /opt/test/perl/;
perl_require switcher_test.pm;
perl_set $test switcher_test::handler;
log_format cestate '$remote_addr,$http_x_forwarded_for -
$remote_user [$time_local] "$request" $status $body_bytes_sent
"$http_referer" "$http_user_agent" $request_time # $test';
access_log /var/log/nginx/cestate.log cestate;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
My proxy.conf:
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
client_max_body_size 21474836470;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 3600;
proxy_buffers 32 8k;
proxy_max_temp_file_size 0;
My script:
#!/usr/bin/perl
package switcher_test;
use nginx;
sub handler {
my $r = shift;
if($r->has_request_body(sub{})) { return 3 };
return 4;
}
1;
__END__
My vhost on test the value of $test and proxy_pass to the good
upstream.
When Nginx timeout, I have the following log:
2012/08/10 11:56:15 [alert] 30570#0: *1 zero size buf in output t:1 r:0
f:0 0000000001481728 0000000001481728-0000000001481728 0000000000000000
0-0 while sending request to upstream, client: xxx.xxx.xxx.xxx, server:
www.test.com, request: "POST /test.php HTTP/1.1", upstream:
"http://xxx.xxx.xxx.xxx:80/test.php", host: "www.test.com"
2012/08/10 11:56:41 [info] 30580#0: Using 32768KiB of shared memory for
push module in /etc/nginx/nginx.conf:63
Has someone any idea of what's going on ?
Thanks.
Rémi
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,229560,229560#msg-229560
More information about the nginx
mailing list