vkholodkov / nginx-eval-module

A module for evaluating memcached or proxy response into variable
Other
87 stars 44 forks source link

eval-module did not work with proxy_pass when request method is not GET #4

Open sydcurie opened 14 years ago

sydcurie commented 14 years ago

I configured eval-module working with proxy_pass (tomcat,apache), when the request method is "GET" it works well.But when I "POST" a request to nginx , it turned into "GET"(saw it from apache's access_log). I have no idea how to fix this. This is my nginx.conf:

location / { eval_override_content_type text/plain; default_type text/html; eval $resp { proxy_pass http://127.0.0.1:81$request_uri; } echo "test, $resp"; }

vkholodkov commented 14 years ago

Try

eval_override_content_type text/plain; default_type text/html; eval $resp { proxy_pass http://127.0.0.1:81$request_uri; proxy_method GET; proxy_pass_request_body off; }

vkholodkov commented 14 years ago

Seems to be resolved, I'm closing it.

darkweaver87 commented 12 years ago

Hi guys,

Did you manage to make it working ?

I'm working with nginx 1.2.1 and here is my vhost config:

upstream test {
    server 127.0.0.1:8080;
}

server {
    listen      80;
    server_name domain.tld;

    location / {
        #eval_override_content_type text/plain;
        #default_type text/html;
        eval $resp {
            proxy_pass http://test;
            #proxy_method GET;
            #proxy_pass_request_body on;
        }

        echo "test, $request_body";

        access_log /var/log/nginx/nginx.log custom;
    }
}

I tried with the solution you proposed but I need to keep the request method as it is. My need is to intercept each request (GET or POST) sent to nginx and ask a remote server for some informations to determine the upstream to use.

I would greatly appreciate your help.

Rémi

vkholodkov commented 12 years ago

In your case uncommenting "proxy_pass_request_body on" should help.

darkweaver87 commented 12 years ago

Hi,

Thanks for your reply.

With this vhost, I still see GET requests on my upstream when I post something:

upstream test {
    server 127.0.0.1:8080;
}

server {
    listen      80;
    server_name domain.tld;

    location / {
        eval $resp {
            proxy_pass http://test;
            proxy_pass_request_body on;
        }

        echo "test, $resp";

        access_log /var/log/nginx/nginx.log custom;
    }
}

Any idea ?

Rémi

darkweaver87 commented 12 years ago

OK doesn't matter. I used perl embedded module which corresponds better to what I wanted to do.

akshit24 commented 11 months ago

@darkweaver87 Which perl module did you use ?