nginx-eval-module icon indicating copy to clipboard operation
nginx-eval-module copied to clipboard

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

Open sydcurie opened this issue 15 years ago • 7 comments

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"; }

sydcurie avatar Aug 22 '10 08:08 sydcurie

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 avatar Aug 22 '10 11:08 vkholodkov

Seems to be resolved, I'm closing it.

vkholodkov avatar Nov 01 '10 16:11 vkholodkov

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

darkweaver87 avatar Jul 20 '12 07:07 darkweaver87

In your case uncommenting "proxy_pass_request_body on" should help.

vkholodkov avatar Jul 20 '12 09:07 vkholodkov

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 avatar Jul 20 '12 09:07 darkweaver87

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

darkweaver87 avatar Jul 26 '12 17:07 darkweaver87

@darkweaver87 Which perl module did you use ?

akshit24 avatar Dec 21 '23 09:12 akshit24