vkholodkov / nginx-eval-module Goto Github PK
View Code? Open in Web Editor NEWA module for evaluating memcached or proxy response into variable
License: Other
A module for evaluating memcached or proxy response into variable
License: Other
Hi, Valery
I've tried to compile other nginx versions (1.0.11 - 1.1.15) on server with gcc 4.6.2 with last (125fa2e) version of that module and it was failed with such errors:
../nginx-eval-module/ngx_http_eval_module.c: In function ‘ngx_http_eval_block’:
../nginx-eval-module/ngx_http_eval_module.c:640:39: error: variable ‘pclcf’ set but not used [-Werror=unused-but-set-variable]
../nginx-eval-module/ngx_http_eval_module.c:631:32: error: variable ‘ecf’ set but not used [-Werror=unused-but-set-variable]
The problem is - new gcc becomes smarter and for now unused variables throws warnings. Nginx default config is:
-Werror=unused-but-set-variable]
BTW, with gcc 4.5.2 all was compiled successfully.
So, it would be great to fix module instead of changing nginx default options.
Thank you!
Vadim.
Прописал
set $memcached_key "$request_uri";
Проверил, плеер передаёт кучу параметров.
/img_v/mp4-public/uuu_d2257c3c21eab413fdf7c4891bb1a3a9_00068006.flv?start=0&id=mediaplayer&client=FLASH%2520WIN%252010,1,85,3&version=4.3.132&width=400
а мне нужен только /img_v/mp4-public/uuu_d2257c3c21eab413fdf7c4891bb1a3a9_00068006.flv
в качестве ключа, в каком месте модуля нужно пофиксить? Я могу руками под себя править при каждой новой версии модуля :(
Не думаю что init согласится.
Nginx is compiled only with this module.
I've downloaded module from:
http://www.grid.net.ru/nginx/download/nginx_eval_module-1.0.1.tar.gz
And it hangs on request.
worker_processes 1;
error_log logs/error.log info;
events {
use epoll;
worker_connections 1024;
multi_accept on;
}
http {
include mime.types;
default_type text/plain;
sendfile on;
keepalive_timeout 5;
server {
listen 80;
server_name test.local;
location / {
eval $res {
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8081/check;
}
if ($res = 'spam') {
return 401;
}
if ($res != 'spam') {
return 404;
}
}
}
}
I can see communication with my upstream server:
127.000.000.001.42387-127.000.000.001.08081: GET /check HTTP/1.0
Host: test.local
Connection: close
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: pl,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Cache-Control: max-age=0
127.000.000.001.08081-127.000.000.001.42387: HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Length: 11
Date: Sun, 30 Mar 2014 11:37:29 GMT
Connection: close
exampletext
Request and response are OK but after that nothing happend. Request hangs...
From port 80 perspective I have:
010.000.002.002.54814-010.000.002.015.00080: GET / HTTP/1.1
Host: test.local
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: pl,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cache-Control: max-age=0
And after couple of seconds connection is closed.
Help me. Thanks!
I am using this eval module to capture response from google recaptcha service. But whenever I am trying to reload nginx, it keeps showing segmentation fault. I think the issue is that the variable initialized with eval module is storing null value, that's why it is showing segmentation fault. Can you suggest any corrections, or workaround if possible?
I want to use nginx-eval-module to get the response from tomcat , this is my config:
eval $res {
proxy_pass http://127.0.0.1:8080;
}
echo $res;
After waiting a long time , it returns nothing.If I do not use nginx-eval-module , just use proxy_pass , it works well , config is like this:
proxy_pass http://127.0.0.1:8080;
I was excited to learn recently that SPDY is now supported by Nginx 1.3.x. It is a new type of networking protocol developed at Google that can reportedly speed up HTTPS page loading by as much as 39% - 55%. Unfortunately, as soon as I tried it on my site, which uses the Eval module for retrieving data from Memcached, I began getting the following error message when accessing a page with HTTPS:
Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.
This is the message that occurs in the Google Chrome browser but all browsers fail to load the page since no page body is sent in the response from nginx.
When disabling "spdy" in my config, or when commenting out my "eval" block, my site began to work normally again. I am not sure if it is even possible to get both of these working together, but it would be great to know if this is possible to fix. I love your module!
The instructions for installing SPDY with NGINX are found here:
http://nginx.org/patches/spdy/README.txt
My problematic eval block is only two lines, just like in the example:
eval $var {
set $memcached_key $1;
memcached_pass 192.168.2.1;
}
For some reason I am unable to install it on my server. When I do make I get these errors:
/root/src/nginx_eval_module-1.0.1/ngx_http_eval_module.c: In function ‘ngx_http_eval_block’:
/root/src/nginx_eval_module-1.0.1/ngx_http_eval_module.c:531:39: error: variable ‘pclcf’ set but not used [-Werror=unused-but-set-variable]
/root/src/nginx_eval_module-1.0.1/ngx_http_eval_module.c:522:32: error: variable ‘ecf’ set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[1]: *** [objs/addon/nginx_eval_module-1.0.1/ngx_http_eval_module.o] Error 1
make[1]: Leaving directory `/root/src/nginx-1.2.7'
make: *** [build] Error 2
I am trying to use eval with the redis2 nginx plugin. I want to get the backend server name from redis.
I am trying with this:
location / {
eval $answer {
redis2_raw_query 'get server_name\r\n';
eval_override_content_type text/plain;
redis2_pass 127.0.0.1:6379;
}
proxy_pass $answer;
But that doesn't work because the redis response has the string length at the beginning of the response. So you get:
2010/12/28 17:05:34 [error] 52979#0: *73 invalid URL prefix in "$24
http://127.0.0.1/foo//" while sending to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
Any ideas?
Hi, Valery!
Piotr Sikora and I have just noticed that your eval module does not work with the latest 0.8.42 release of nginx (empty content in the output variables) but fine with earlier versions including 0.8.41. Could you please look into this?
Thanks!
-agentzh
My config. Nginx is compiled only with this module. And it hangs on request.
events {
use epoll;
worker_connections 20480;
multi_accept on;
}
http{
server {
listen 80;
location / {
eval $var {
proxy_pass http://77.88.21.3:80/$request_uri;
}
}
}
}
I have this need:
1, A request is sent to backend server with eval module.
2, If the eval response is '0', I want to rewrite this request to a second location.
3, In the second location, I also have a eval module. But It seem that the eval does not work in this location.
I changed the source a little, It seems works for me:
diff --git a/ngx_http_eval_module.c b/ngx_http_eval_module.c
index 402bbb6..fb7eaab 100644
--- a/ngx_http_eval_module.c
+++ b/ngx_http_eval_module.c
@@ -180,6 +180,16 @@ ngx_http_eval_handler(ngx_http_request_t *r)
ngx_http_set_ctx(r, ctx, ngx_http_eval_module);
}
ctx->in_progress = 0;
ctx->done = 0;
ctx->base_conf = ecf;
ctx->current_block = ecf->blocks->elts;
ctx->last_block = ctx->current_block + ecf->blocks->nelts - 1;
if(ctx->done) {
ctx->in_progress = 0;
Hi, Valery
I've tried to compile other nginx versions (1.0.11 - 1.1.15) on server with gcc 4.6.2 with last (125fa2e) version of that module and it was failed with such errors:
../nginx-eval-module/ngx_http_eval_module.c: In function ‘ngx_http_eval_block’:
../nginx-eval-module/ngx_http_eval_module.c:640:39: error: variable ‘pclcf’ set but not used [-Werror=unused-but-set-variable]
../nginx-eval-module/ngx_http_eval_module.c:631:32: error: variable ‘ecf’ set but not used [-Werror=unused-but-set-variable]
The problem is - new gcc becomes smarter and for now unused variables throws warnings. Nginx default config is:
-Werror=unused-but-set-variable]
So, it would be great to fix module instead of changing nginx default options.
Thank you!
Vadim.
since 11f7161 module modifies nginx global variable r->uri, it brokes data used by other modules (my closed-source advertising module for example)
problem line marked with comment:
http://github.com/vkholodkov/nginx-eval-module/commit/11f7161db92bf811f467ede1f64ec56bd0fd5ee4#commitcomment-64250
possible patch:
http://github.com/agentzh/nginx-eval-module/commit/f9825f572a68320c369c86f93d5de406c60ddeb7
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 Can you tag a new 1.0.4
release that includes the fix from #17 ?
It works if built statically (though with bugs, can't read body sent by eval module via proxy_pass). But refuses to load as a dynamic module. This is a backtrace:
GNU gdb (GDB) 11.1
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from nginx...
(No debugging symbols found in nginx)
[New LWP 16]
Core was generated by `nginx -t'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 ngx_http_eval_merge_loc_conf (cf=0x7ffc2dec70c8, parent=0x7fc63fbcd298, child=0x0) at //nginx-eval-module-1.0.4/ngx_http_eval_module.c:525
525 //nginx-eval-module-1.0.4/ngx_http_eval_module.c: No such file or directory.
I build modules
, configuring nginx sources like this:
./configure --add-dynamic-module=$NGINX_EVAL_DIR --with-compat $CONFARGS
where CONFARGS - are configure arguments for Nginx in the container.
Then I copy .so to another exactly the same container as nginx module (to /etc/nginx/modules/
) without build requirements installed (nginxes are the same with the same CONFARGS).
For example headers-more-nginx-module
built in the same way loads well.
This is error:
/home/mimiko/src/nginx-modules/nginx-eval-module/ngx_http_eval_module.c
/home/mimiko/src/nginx-modules/nginx-eval-module/ngx_http_eval_module.c: In function Б-?ngx_http_eval_blockБ-?:
/home/mimiko/src/nginx-modules/nginx-eval-module/ngx_http_eval_module.c:640:39: error: variable Б-?pclcfБ-? set but not used [-Werror=unused-but-set-variable]
/home/mimiko/src/nginx-modules/nginx-eval-module/ngx_http_eval_module.c:631:32: error: variable Б-?ecfБ-? set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[1]: *** [objs/addon/nginx-eval-module/ngx_http_eval_module.o] Error 1
make[1]: Leaving directory `/home/mimiko/src/nginx'
make: *** [build] Error 2
http://github.com/vkholodkov/nginx-eval-module/blob/master/ngx_http_eval_module.c
Тестировал с nginx-0.7.67 и nginx-0.8.53
1.0.1 с to_uri.patch работает в nginx-0.7.67 а в старших 0.8.* нет
eval_escalate on;
eval $path {
set $memcached_key "$uri";
memcached_pass 10.0.0.3:11211;
}
root /farm-a-02;
try_files /$path @blah;
В memcached он запрашивает /eval_*****
<30 new auto-negotiating client connection
30: Client using the ascii protocol
<30 get /eval_256556512
30 END
<30 connection closed.
error.log
http uri: "/img_v/mp4-public/uuu_d2257c3c21eab413fdf7c4891bb1a3a9_00068006.flv"
http subrequest "/eval_527896408?"
http posted request: "/eval_527896408?"
http script complex value
http script var: "/eval_527896408"
http script set $memcached_key
key: "/eval_527896408" was not found by memcached while reading response header from upstream
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.