Modify request body before sending to upstream

abhinanda nginx-forum at nginx.us
Tue Jan 27 07:06:25 UTC 2015


Still no luck. Here's my config:

upstream wservers {
    server localhost:8001 max_fails=3 fail_timeout=2s weight=100;
    server localhost:8002 max_fails=3 fail_timeout=2s weight=100;
}

server {
    location /foo {
        rewrite_by_lua '
            ngx.print("yay")
        ';
        proxy_pass http://wservers;
    }

    location /bar {
        proxy_pass http://wservers;
    }
}


Here are the curl commands:


[vm ~]$ curl localhost:8080/bar -X POST --data 'hello'
UPSTREAM: hello :UPSTREAM
[vm ~]$ curl localhost:8080/foo -X POST --data 'hello'
yay


What I need is for the second curl command to output:
UPSTREAM: yay :UPSTREAM

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,256226,256285#msg-256285



More information about the nginx mailing list