Open fatalafitili opened 5 years ago
@fatalafitili I tested that the access_by_php directive was not executed.Need to research in depth.
@rryqszq4 I wait u
@fatalafitili The 'return' directive is in the 'rewrite' phase, earlier than the 'access' phase.
Try the following example:
...
set $sel 0;
location = / {
access_by_php '
$x = 1;
ngx_var::set("sel", $x);
';
content_by_php '
echo ngx_var::get("sel");
';
}
...
@fatalafitili The 'return' directive is in the 'rewrite' phase, earlier than the 'access' phase.
Try the following example:
... set $sel 0; location = / { access_by_php ' $x = 1; ngx_var::set("sel", $x); '; content_by_php ' echo ngx_var::get("sel"); '; } ...
I know it works but I want to change a variable in nginx.
for example
`set $sel 0;
location = / {
access_by_php '
$x = 1;
ngx_var::set("sel", $x);
';
content_by_php '
echo ngx_var::get("sel");
';
if ($sel = 1) {
#I want to make transactions here
}
}`
@rryqszq4 Isn't it possible ?
@fatalafitili For example about what transactions?
@rryqszq4 My only goal is to change the value of a nginx variable with php, I can use that variable in all fields, usually if parameter
@fatalafitili I think the ‘rewrite_by_php’ directive should be used, but there are some bugs. =.=
@rryqszq4
Okay, buddy, I'm gonna do it for now, but I'm waiting for an update. :)
@fatalafitili
Change access_by_php to rewrite_by_php, I found it is ok.
...
set $sel 0;
location = / {
rewrite_by_php '
$x = 1;
ngx_var::set("sel", $x);
';
return 200 $sel;
}
...
@fatalafitili
Change access_by_php to rewrite_by_php, I found it is ok.
... set $sel 0; location = / { rewrite_by_php ' $x = 1; ngx_var::set("sel", $x); '; return 200 $sel; } ...
Oh I so happy, this worked thanks dude, i love u <3 @rryqszq4
Hello dude i again here :) my problem is not fully solved, look this;
it's not complete, but it's logic
i did use this but this is not worked, 404 does not;
i need this:
Example:
(php counts how many times each user enters)
php variable if 100, nginx variable 1 do
if nginx variable 1, go return 404 else go location /
i need to do this, can u help again me ? @rryqszq4
That's the right logic, but it doesn't work;
`user www www; worker_processes 4;
events { worker_connections 1024; }
http { include mime.types; default_type application/octet-stream;
}`
return 200 $sel; 0 gives
How ı can do ? Can u help me ?