Welcome! Log In Create A New Profile

Advanced

nginx+lua reverse proxy empty body

Bart van Deenen
November 27, 2012 05:30AM
Hi all

I'm trying to do on-the-fly changes on the pages of a site using lua.
I've set up a nginx reverse proxy, and some lua code to do the
replacements, and I notice irreproducable (timing ?) situations where
the proxied body that is passed to lua is empty. I know my code works in
some cases, but I can't figure out what makes that it's not reliable.

nginx.conf:

worker_processes 1;
error_log logs/error.log debug;
events {
worker_connections 1024;
}
http {
server {
client_body_in_single_buffer on;
listen 9001;

location / {
proxy_pass http://www.spelletjes.nl:80;
proxy_set_header X-Real-IP $remote_addr;
body_filter_by_lua '

if ngx.arg[1] ~= "" then
ngx.arg[1] = string.gsub(ngx.arg[1], "Speel", "NGINX")
else
print(ngx.var.uri .. " has empty body" .. ngx.arg[1])
end
';
}
}
}
The problem I have basically that the ngx.arg[1] is an empty string
(sometimes, timing dependent?) on url's that are definitely not empty.


So what am I doing wrong? I am using openresty 1.2.4.9 (nginx 1.2.4 +
ngx_lua-0.7.5)

Typical message in logs/error.log:
67 2012/11/26 14:53:59 [notice] 19291#0: *55 [lua] [string
"body_filter_by_lua"]:7: / has empty body while sending to
client, client: 127.0.0.1, server: , request: "GET / HTTP/1.1",
upstream: "http://212.72.60.220:80/ ", host: "localhost:9001"


Thanks for answers

Bart

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

nginx+lua reverse proxy empty body

Bart van Deenen November 27, 2012 05:30AM

Re: nginx+lua reverse proxy empty body

agentzh November 27, 2012 06:44PM

RE: nginx+lua reverse proxy empty body

Bart van Deenen November 28, 2012 10:30AM

Re: nginx+lua reverse proxy empty body

agentzh November 29, 2012 08:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 189
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready