I worked with Phalcon and Volt under WAMP. Recently we moved to another dev environment (CentOS) and there I have PHP 5.5.17 with latest Phalcon build (I compiled and tested 2 versions lower as well).
Now, when Volt tries to compile template with custom function, it crashes (PHP process). The same is
about custom filters.
Error log of Apache
[Tue Sep 30 06:06:24.809476 2014] [proxy_fcgi:error] [pid 31199:tid 140596014397184] (104)Connection reset by peer: [client 10.0.2.2:53931] AH01075: Error dispatching request to :3080:
[Tue Sep 30 06:06:27.216226 2014] [proxy_fcgi:error] [pid 31200:tid 140596161255168] [client 10.0.2.2:53941] AH01067: Failed to read FastCGI header
[Tue Sep 30 06:06:27.216249 2014] [proxy_fcgi:error] [pid 31200:tid 140596161255168] (104)Connection reset by peer: [client 10.0.2.2:53941] AH01075: Error dispatching request to :3080:
PHP error log
[30-Sep-2014 06:06:27] WARNING: [pool www] child 32519 exited on signal 11 (SIGSEGV - core dumped) after 204.725812 seconds from start
[30-Sep-2014 06:06:27] NOTICE: [pool www] child 32529 started
PHP code looks like
$di->set('view', function () use ($config) {
$view = new View();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(array(
'.volt' => function ($view, $di) use ($config) {
$volt = new VoltEngine($view, $di);
$volt->setOptions(array(
'compiledPath' => $config->application->cacheDir,
'compiledSeparator' => '_',
'compileAlways' => $config->application->debug
));
$compiler = $volt->getCompiler();
$compiler->addFunction(
'last',
function ($resolvedArgs) use ($compiler) {
return 'array_pop('. $resolvedArgs .')';
}
);
return $volt;
}
));
return $view;
}, true);
And in Volt for example
{{ last(['1', '2', '3']) }}
And I really stuck on this problem, because I have pretty a lot of custom functions and I do need them. Tried to debug it, but, as soon as volt tried to parse line with custom function, process die.
Phalcon bug submitted. Solution: totally disable xdebug for current build. More here: https://github.com/xdebug/xdebug/pull/120
Related
I am experimenting with setting up an Apache server and running some perl scripts on it, but I'm running into some issues with my Apache and Perl config.
Initially, I was getting a 500 server error when trying to run a cgi script, and the error log showed that Apache was looking in the wrong #INC for a module I was running.
So, in httpd.conf, I added this line:
SetEnv PERL5LIB /Users/rasha/.plenv/versions/5.34.0/lib/perl5/site_perl/5.34.0/darwin-2level:/Users/rasha/.plenv/versions/5.34.0/lib/perl5/site_perl/5.34.0:/Users/rasha/.plenv/versions/5.34.0/lib/perl5/5.34.0/darwin-2level:/Users/rasha/.plenv/versions/5.34.0/lib/perl5/5.34.0
which I got by running: perl -e 'print join "\n", #INC;'
Now I am still getting a 500 server error, but with a different error message:
[Tue Feb 22 14:24:32.919661 2022] [cgi:error] [pid 35434] [client 127.0.0.1:55187] AH01215: Can't load '/Users/rasha/.plenv/versions/5.34.0/lib/perl5/site_perl/5.34.0/darwin-2level/auto/List/Util/Util.bundle' for module List::Util: dlopen(/Users/rasha/.plenv/versions/5.34.0/lib/perl5/site_perl/5.34.0/darwin-2level/auto/List/Util/Util.bundle, 0x0001): symbol not found in flat namespace '_PL_DBsub' at /Users/rasha/.plenv/versions/5.34.0/lib/perl5/5.34.0/XSLoader.pm line 96.: /usr/local/var/www/cgi-bin/test
The test script I am trying to run:
#!/usr/bin/env perl
use strict;
use warnings;
use DBI;
use CGI qw(:standard);
my ($dbh, $sth, $count);
$dbh = DBI->connect("DBI:mysql:host=localhost;database=xxxx",
"xxxx", "xxxx",
{PrintError => 0, RaiseError => 1});
$sth = $dbh->prepare("Select name, wins, losses from teams");
$sth->execute;
print header, start_html("team data");
$count = 0;
while (my #val = $sth->fetchrow_array) {
print p (sprintf ("name = %s, wins = %d, losses = %d\n", $val[0], $val[1], $val[2]));
$count++;
};
print p("$count rows total"), end_html;
$sth->finish;
$dbh->disconnect;
Does anyone have any ideas what the issue might be?
(Code is locally tested on a mac)
I've created a simple test for Redis, but it, unfortunately, fails with [1] 27996 segmentation fault:
// Config in App.php
// Had to rename Redis, because of the use of phpredis!
'RedisManager' => Illuminate\Support\Facades\Redis::class,
//Test unit
use Illuminate\Support\Facades\Redis;
/** #test */
public function it_can_set_a_dummy_value_in_redis()
{
$value = 'Hello';
Redis::set($this->cacheKey, $value, 'EX', 60);
$this->assertEquals($value, Redis::get($this->cacheKey));
}
It fails when the command set is fired.
I went through the code up to the point: Illuminate\Redis\Connections\PhpRedisConnection.php#command
I checked what the object-value of $this->client is:
Redis {#2278
isConnected: true
host: "127.0.0.1"
port: 6379
auth: null
mode: ATOMIC
dbNum: 0
timeout: 0.0
lastError: null
persistentId: null
options: {
TCP_KEEPALIVE: 0
READ_TIMEOUT: 0.0
COMPRESSION: NONE
SERIALIZER: NONE
PREFIX: "local_database_"
SCAN: NORETRY
}
}
I check the connection with:
dd($this->client->ping()); // it's true
However, it fails at the point:
return parent::command($method, $parameters); //set is called
Even though it is in a try-catch-block, it won't be shown there...
The logs show nothing:
nginx: 0 errors
php-fpm: 0 errors
redis:
2867:M 29 Aug 2020 22:46:03.142 * Background saving started by pid 27498
27498:C 29 Aug 2020 22:46:03.145 * DB saved on disk
2867:M 29 Aug 2020 22:46:03.306 * Background saving terminated with success
So even Redis is working correctly.
I don't know what is going on. When I change to predis, everything works fine!
The only hint I have got is this thread. But since my ping() is ponged, it should work?
Any ideas how I can fix my problem?
Trying to implement fail2ban on a Linux Mint 17.1 and cant seem to get it to ban me after multiple login attempts against apache-auth.
I followed this guide to get started.
I think its a problem with the apache-auth regex but cant get it right.
jail.local
[apache]
enabled = true
port = 80,443
filter = apache-auth
logpath = /var/log/apache2/*error.log
maxretry = 3
bantime = 600
##ignoreip = 192.168.3.70
##To block the remote host that is trying to request suspicious URLs, use the below jail.
[apache-overflows]
enabled = true
port = http,https
filter = apache-overflows
logpath = /var/log/apache2/*error.log
maxretry = 3
bantime = 600
ignoreip = 192.168.3.70
##To block the remote host that is trying to search for scripts on the website to execute, use the below jail.
[apache-noscript]
enabled = true
port = http,https
filter = apache-noscript
logpath = /var/log/apache2/*error.log
maxretry = 3
bantime = 600
ignoreip = 192.168.3.70
##To block the remote host that is trying to request malicious bot, use below jail.
[apache-badbots]
enabled = true
port = http,https
filter = apache-badbots
logpath = /var/log/apache2/*error.log
maxretry = 3
bantime = 600
ignoreip = 192.168.3.70
##To stop DOS attack from remote host.
[http-get-dos]
enabled = true
port = http,https
filter = http-get-dos
logpath = /var/log/apache*/access.log
maxretry = 400
findtime = 400
bantime = 200
##ignoreip = 192.168.3.70
action = iptables[name=HTTP, port=http, protocol=tcp]
apache-auth.conf
[INCLUDES]
before = apache-common.conf
[Definition]
failregex = ^%(_apache_error_client)s (AH01797: )?client denied by server configuration: (uri )?\S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01617: )?user .*? authentication failure for "\S*": Password Mismatch(, referer: \S+)?$
^%(_apache_error_client)s (AH01618: )?user .*? not found(: )?\S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01614: )?client used wrong authentication scheme: \S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH\d+: )?Authorization of user \S+ to access \S* failed, reason: .*$
^%(_apache_error_client)s (AH0179[24]: )?(Digest: )?user .*?: password mismatch: \S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH0179[01]: |Digest: )user `.*?' in realm `.+' (not found|denied by provider): \S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01631: )?user .*?: authorization failure for "\S*":(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01775: )?(Digest: )?invalid nonce .* received - length is not \S+(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01788: )?(Digest: )?realm mismatch - got `.*?' but expected `.+'(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01789: )?(Digest: )?unknown algorithm `.*?' received: \S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01793: )?invalid qop `.*?' received: \S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01777: )?(Digest: )?invalid nonce .*? received - user attempted time travel(, referer: \S+)?\s*$
apache-common.conf
_apache_error_client = \[[^]]*\] \[(error|\S+:\S+)\]( \[pid \d+:\S+\d+\])? \[client <HOST>(:\d{1,5})?\]
/var/log/apache2/error.log
[Thu Aug 02 23:03:42.143209 2018] [auth_basic:error] [pid 8025] [client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
[Thu Aug 02 23:03:43.216097 2018] [auth_basic:error] [pid 8025] [client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
[Thu Aug 02 23:03:44.124570 2018] [auth_basic:error] [pid 8025][client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
[Thu Aug 02 23:03:45.104747 2018] [auth_basic:error] [pid 8025][client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
[Thu Aug 02 23:03:46.001161 2018] [auth_basic:error] [pid 8025][client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
[Thu Aug 02 23:03:46.871802 2018] [auth_basic:error] [pid 8025][client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
[Thu Aug 02 23:03:47.843740 2018] [auth_basic:error] [pid 8025][client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
As I said I think the problem is in the regex, since the http-get-dos jail worked fine. The regex for apache-common.conf doesn't look right since my log files seem to follow a different standard, BUT I'm not sure if that's true or how to properly format the regex.
ANy help is appreciated.
Found my problem
I had to change the line in apache-common.conf to the following;
_apache_error_client = \[[^]]*\] \[(error|\S+:\S+)\]( \[pid \d+\])? \[client <HOST>(:\d{1,5})?\]
The difference being in the PID section. I used Regex101 to work the expression until it matched.
I have a live website and staging version set up on the same virtual server. The live site uses Varnish and no authentication, the staging site bypasses Varnish but uses digest authentication. In my VCL file I have this:
sub vcl_recv {
if (req.http.Authorization || req.http.Authenticate) {
return(pass);
}
if (req.http.host != "live.site.com") {
return(pass);
}
I'm seeing a problem on the staging site, whereby resources with any querystring are not being served - in Firebug I see '400 Bad request' and in the Apache logs this:
[Fri Sep 19 11:13:03 2014] [error] [client 127.0.0.1] Digest: uri mismatch -
</wp-content/plugins/jetpack/modules/wpgroho.js?ver=3.9.2> does not match
request-uri </wp-content/plugins/jetpack/modules/wpgroho.js>, referer:
http://stage.site.com/
What have I done wrong, does anyone know how to fix this?
Thanks,
Toby
Ok, found it, here's what I found (in case it helps anyone else):
I do, of course, have a section in my Varnish VCL that removes querystrings from static files, to aid caching:
if (req.request ~ "^(GET|HEAD)$" && req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)(\?.*)?$") {
if (req.url ~ "nocache") {
return(pass);
}
set req.url = regsub(req.url, "\?.*$", "");
unset req.http.Cookie;
set req.grace = 2m;
return(lookup);
}
This clearly conflicts with digest authentication, so I will have to revisit that part of the VCL.
UPDATE I just changed the second conditional to:
if (req.http.Authorization || req.http.Authenticate ||
req.url ~ "nocache") {
return(pass);
}
I have this PHP code :
error_log('my message 1');
....
error_log('my message 2');
...
error_log('my message 3');
This produces in apache error_log one line with all messages :
[Wed Nov 13 17:24:55.880399 2013] [proxy_fcgi:error] [pid xx] [client xxx] AH01071: Got error 'PHP message: my message 1\n'PHP message: my message 2\n'PHP message: my message 3
My config :
Apache 2.4
PHP : 5.4
PHP-FPM with proxypassmatch directive.
My question : Why messages are on the same line, and how to do to have one line per message ?
Thanks for yours answers.
EDIT
One line per message should look like :
[Wed Nov 13 17:24:55.880399 2013] [proxy_fcgi:error] [pid xx] [client xxx] AH01071: Got error 'PHP message: my message 1'
[Wed Nov 13 17:24:55.880399 2013] [proxy_fcgi:error] [pid xx] [client xxx] AH01071: Got error 'PHP message: my message 2'
[Wed Nov 13 17:24:55.880399 2013] [proxy_fcgi:error] [pid xx] [client xxx] AH01071: Got error 'PHP message: my message 3'
error_log("error message \r\n");
PHP disregards special ASCII characters within single quotes(it renders it as separate chars), you need to use double quotes.
In addition:
You should open your php.ini file, the one in the /etc/php5/apache2/ folder, and chnage the error_log directive to point to a file.
It is important that Apache will have sufficient privileges to write into this file.
so
chown www-data:www-data /var/www/somefile.log
should do it
If it's currently undefined, the logs will go through syslog, and there new lines are not allowed.
Additional edit:
To penetrate output buffering you need to raise an exception.
example:
try{
ob_start();
doSomething($userInput);
ob_end_flush();
}
catch(Exception $e){
error_log($e->getMessage());
}
function doSomething($data = null){
if($data === null){
throw new Exception("Data is required");
}
else{
//do something
}
}
User \r\n
error_log("my message 1\r\n");
....
error_log("my message 2\r\n");
...
error_log("my message 3\r\n");