Welcome! Log In Create A New Profile

Advanced

[Nginx] perl module get an empty body

August 10, 2012 06:03AM
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
Subject Author Posted

[Nginx] perl module get an empty body

darkweaver871 August 10, 2012 06:03AM

Re: [Nginx] perl module get an empty body

darkweaver871 August 10, 2012 06:04AM

Re: [Nginx] perl module get an empty body

darkweaver871 August 10, 2012 07:03AM

Re: [Nginx] perl module get an empty body

darkweaver871 August 10, 2012 09:44AM

Re: [Nginx] perl module get an empty body

Maxim Dounin August 10, 2012 07:14AM

Re: [Nginx] perl module get an empty body

darkweaver871 August 10, 2012 09:46AM

Re: [Nginx] perl module get an empty body

darkweaver871 August 10, 2012 10:12AM

Re: [Nginx] perl module get an empty body

Maxim Dounin August 10, 2012 09:56AM

Re: [Nginx] perl module get an empty body

Maxim Dounin August 10, 2012 01:12PM

Re: [Nginx] perl module get an empty body

darkweaver871 August 12, 2012 06:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 84
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready