Control Web Panel

WebPanel => CentOS 7 Problems => Topic started by: Orlox on November 18, 2020, 05:46:38 PM

Title: Cwppro - Huge log files in
Post by: Orlox on November 18, 2020, 05:46:38 PM
in /usr/local/apache/domlogs I saw some huge logs. I deleted them and after 24 hours I again see logs around 300GBs (server full  :P)

How can I put a size limit to this or tie them with the users quota space?

Thank you.
Title: Re: Cwppro - Huge log files in
Post by: Orlox on November 18, 2020, 06:52:29 PM
So I found a semi solution here http://forum.centos-webpanel.com/index.php?topic=6156.0
But the question still stands How can I put a size limit to this or tie them with the users quota space?
Title: Re: Cwppro - Huge log files in
Post by: cinique on November 18, 2020, 10:59:32 PM
So I found a semi solution here http://forum.centos-webpanel.com/index.php?topic=6156.0
But the question still stands How can I put a size limit to this or tie them with the users quota space?
You read/learn about logrotate and CWP even provide you with a GUI to configure.
Title: Re: Cwppro - Huge log files in
Post by: narin on November 19, 2020, 09:33:04 AM
So I found a semi solution here http://forum.centos-webpanel.com/index.php?topic=6156.0
But the question still stands How can I put a size limit to this or tie them with the users quota space?

Are you using wordpress or similar software on your website?

If so, you may be getting this error due to the plugins you use on your website.

Recently, 150 GB of log file of one of our customers had accumulated due to the YOAST extension.

After deleting the log file, follow it instantly, the records to be written to the file will be useful for solution.
Title: Re: Cwppro - Huge log files in
Post by: Orlox on November 19, 2020, 04:05:03 PM
So I found a semi solution here http://forum.centos-webpanel.com/index.php?topic=6156.0
But the question still stands How can I put a size limit to this or tie them with the users quota space?
You read/learn about logrotate and CWP even provide you with a GUI to configure.

Thank you for the answer, thats what I did, but it is not logical for this to happen in the first place. (it does not happen with other panels for example).

Logs should be moved inside users directories (so each user should be responsible for his space) and their size should be contained with the installation of cwp.
What if a user creates huge logfiles on purpuse in minutes? Logrotate cannot help you (in my knowleage) in this case and a user can destroy the whole server.

I think yoast or user activity monitor caused the issue.
Title: Re: Cwppro - Huge log files in
Post by: cinique on November 19, 2020, 07:51:41 PM
So you haven't used open_basedir protection? Otherwise, other panels are the same, IIRC.
Title: Re: Cwppro - Huge log files in
Post by: Orlox on November 20, 2020, 02:23:58 PM
No I have not. I supposed that its enabled by default.
I could not find any option for this in the panel. Only this article.
https://wiki.centos-webpanel.com/php-open_basedir
So I will have to manually create the php file for each user? Thats .... extreme :D
Title: Re: Cwppro - Huge log files in
Post by: cinique on November 20, 2020, 02:53:24 PM
Engage brain and use lateral thinking..
Adapt:
Code: [Select]
#!/usr/bin/bash
for i in /home/*
 do
  cp /root/restricted-php.ini /home/$i/php.ini
 done
Title: Re: Cwppro - Huge log files in
Post by: Orlox on November 20, 2020, 03:44:13 PM
much wow, very thanx.

Just for reference
Code: [Select]
cd
Code: [Select]
nano phpopenbasedir
Code: [Select]
#!/usr/bin/bash
for i in /home/*
 do
   FILE=$i/php.ini
   if [[ -f "$FILE" ]]; then
     echo "$FILE exists."
   else
     echo "open_basedir = $i/:/tmp:/var/tmp:/usr/local/lib/php/" > $i/php.ini
     chown root.root $i/php.ini
     chmod 555 $i/php.ini
   fi
 done

(I did not need the second home in "/home/$i/php.ini)

Code: [Select]
chmod +x phpopenbasedir
Now I need a way to run this at every account creation.

PS. Unfortunately phpinfo() shows open_basedir as empty. Maybe its because I have chosen in cwp the nginx, apache, varnish option with the php-fpm option forced?
Title: Re: Cwppro - Huge log files in
Post by: cinique on November 20, 2020, 05:22:17 PM
(I did not need the second home in "/home/$i/php.ini)

Code: [Select]
chmod +x phpopenbasedir
...
PS. Unfortunately phpinfo() shows open_basedir as empty. Maybe its because I have chosen in cwp the nginx, apache, varnish option with the php-fpm option forced?
You should/must put the full path in, otherwise i will create the files relative to your current path and likely fail.
You're not making it clear where your storing the script. ;)
I don't use that web stack so won't comment on that.
Title: Re: Cwppro - Huge log files in
Post by: Orlox on November 20, 2020, 05:49:58 PM
Thank you for taking interest on a noob.
I think, the files where created where they should have been:
Code: [Select]
[root@srv ~]# ./phpopenbasedir
/home/byron/php.ini exists.
/home/Byron/php.ini exists.
/home/chalioti/php.ini exists.
/home/estudy1n/php.ini exists.
/home/jfoundis/php.ini exists.
and
Code: [Select]
[root@srv ~]# cat /home/byron/php.ini
open_basedir = /home/byron/:/tmp:/var/tmp:/usr/local/lib/php/

I think there is an issue with fpm and php.ini / .user.ini

Someone else also reported it at http://forum.centos-webpanel.com/index.php?topic=294.0

I think the fpm simply is not reading the php.ini from inside the users root directory.

PS. You are already setting the full path for i at /home/ thats why it is not needed. If you use it as you have written it will produce a "/home/home/username....".
Title: Re: Cwppro - Huge log files in
Post by: cinique on November 20, 2020, 06:04:59 PM
Ahh, it's prepending from the directory listing - gotcha.
PHP-FPM ignores php.ini and uses .user.ini
Risky, though it will just take the last entry, if one exists
Code: [Select]
echo "open_basedir = $i/:/tmp:/var/tmp:/usr/local/lib/php/" >> $i/.user.ini

Title: Re: Cwppro - Huge log files in
Post by: Orlox on November 20, 2020, 06:33:41 PM
Unfortunately it is the same for .user.ini.
The only way i could affect the php info is to put the open_basedir= /home:/tmp:/var/tmp:/usr/local/lib/php/
inside /opt/alt/php-fpm73/usr/php/php.ini using the cwp php.ini editor from "PHP FPM SELECTOR" menu and reloading php-fpm
Title: Re: Cwppro - Huge log files in
Post by: cinique on November 20, 2020, 08:03:44 PM
Have you been remembering to restart all the services; Apache/ngix/Varnish/PHP?
Code: [Select]
open_basedir= /home:/tmp:/var/tmp:/usr/local/lib/php/.. is not great as it allows users access above the level that they should have access to.
Try
Code: [Select]
open_basedir= ~/:/tmp:/var/tmp:/usr/local/lib/php/Note: I have NOT tested this.

https://serverfault.com/questions/431200/how-to-add-an-open-basedir-path-in-nginx-vhost
Title: Re: Cwppro - Huge log files in
Post by: cinique on November 21, 2020, 10:32:45 AM
@Oriox
See @Studio4host comprehensive reply to:
http://forum.centos-webpanel.com/index.php?topic=294.msg34521
Title: Re: Cwppro - Huge log files in
Post by: Orlox on November 21, 2020, 06:52:14 PM
Thank you. That worked with a little twining.

For the domlogs I enabled log rotate from cwp admin
->
File manager -> Logrotate manager -> Add new conf file
at filename I put
domlogs

As contents I used:

Code: [Select]
/usr/local/apache/domlogs/*.log {
    rotate 7
    daily
    missingok
    notifempty
    sharedscripts
    compress
    minsize 1048576
    delaycompress
    postrotate
/bin/kill -HUP `cat /usr/local/apache/logs/httpd.pid 2>/dev/null` 2> /dev/null || true
    endscript
}
After clicking save, I also run it once.
Title: Re: Cwppro - Huge log files in
Post by: legija on November 27, 2020, 09:54:56 AM
Once everything start to work, I configure logs to /dev/null :D