I have some fresh web servers with ubuntu 22 LTS runnings apache2 and php-fpm with mpm_event.
All of them behave the same. After 8-12 days of apache uptime. It suddenly stops recieving requests untill i restart apache2 manually. Then it run fine again for another 10 days.
It crashes at random times
Here is output from netstat Apache seems to only listen on tcp6? Seems wrong.. Should it not also listen on normal tcp?
netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 729/systemd-resolve
tcp 0 0 0.0.0.0:22825 0.0.0.0:* LISTEN 2728/php
tcp 0 0 0.0.0.0:23004 0.0.0.0:* LISTEN 2752/php
tcp 0 0 0.0.0.0:22928 0.0.0.0:* LISTEN 2742/php
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1072/sshd: /usr/sbi
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 971/mysqld
tcp 0 0 127.0.0.1:33060 0.0.0.0:* LISTEN 971/mysqld
tcp6 0 0 :::9100 :::* LISTEN 1074312/node_export
tcp6 71 0 :::80 :::* LISTEN 2207/apache2
tcp6 0 0 :::22 :::* LISTEN 1072/sshd: /usr/sbi
tcp6 512 0 :::443 :::* LISTEN 2207/apache2
udp 0 0 127.0.0.53:53 0.0.0.0:* 729/systemd-resolve
udp 0 0 0.0.0.0:500 0.0.0.0:* 1073/charon
udp 0 0 0.0.0.0:4500 0.0.0.0:* 1073/charon
udp6 0 0 :::500 :::* 1073/charon
udp6 0 0 :::4500 :::* 1073/charon
I also did a stack trace.
strace -o apache.strace -f -p 2207
output:
2207 times({tms_utime=3026 /* 30.26 s */, tms_stime=6010 /* 60.10 s */, tms_cutime=369020 /* 3690.20 s */, tms_cstime=174724 /* 1747.24 s */}) = 1819843146
2207 pselect6(0, NULL, NULL, NULL, {tv_sec=1, tv_nsec=0}, NULL) = 0 (Timeout)
2207 wait4(-1, 0x7ffedc77b084, WNOHANG|WSTOPPED, NULL) = 0
2207 times({tms_utime=3026 /* 30.26 s */, tms_stime=6010 /* 60.10 s */, tms_cutime=369020 /* 3690.20 s */, tms_cstime=174724 /* 1747.24 s */}) = 1819843246
2207 pselect6(0, NULL, NULL, NULL, {tv_sec=1, tv_nsec=0}, NULL) = 0 (Timeout)
2207 wait4(-1, 0x7ffedc77b084, WNOHANG|WSTOPPED, NULL) = 0
2207 times({tms_utime=3026 /* 30.26 s */, tms_stime=6010 /* 60.10 s */, tms_cutime=369020 /* 3690.20 s */, tms_cstime=174724 /* 1747.24 s */}) = 1819843346
2207 pselect6(0, NULL, NULL, NULL, {tv_sec=1, tv_nsec=0}, NULL) = 0 (Timeout)
2207 wait4(-1, 0x7ffedc77b084, WNOHANG|WSTOPPED, NULL) = 0
2207 times({tms_utime=3026 /* 30.26 s */, tms_stime=6010 /* 60.10 s */, tms_cutime=369020 /* 3690.20 s */, tms_cstime=174724 /* 1747.24 s */}) = 1819843446
2207 pselect6(0, NULL, NULL, NULL, {tv_sec=1, tv_nsec=0}, NULL) = 0 (Timeout)
2207 wait4(-1, 0x7ffedc77b084, WNOHANG|WSTOPPED, NULL) = 0
2207 times({tms_utime=3026 /* 30.26 s */, tms_stime=6010 /* 60.10 s */, tms_cutime=369020 /* 3690.20 s */, tms_cstime=174724 /* 1747.24 s */}) = 1819843546
2207 pselect6(0, NULL, NULL, NULL, {tv_sec=1, tv_nsec=0}, NULL) = 0 (Timeout)
2207 wait4(-1, 0x7ffedc77b084, WNOHANG|WSTOPPED, NULL) = 0
2207 times({tms_utime=3026 /* 30.26 s */, tms_stime=6010 /* 60.10 s */, tms_cutime=369020 /* 3690.20 s */, tms_cstime=174724 /* 1747.24 s */}) = 1819843646
2207 pselect6(0, NULL, NULL, NULL, {tv_sec=1, tv_nsec=0}, NULL) = 0 (Timeout)
2207 wait4(-1, 0x7ffedc77b084, WNOHANG|WSTOPPED, NULL) = 0
2207 times({tms_utime=3026 /* 30.26 s */, tms_stime=6010 /* 60.10 s */, tms_cutime=369020 /* 3690.20 s */, tms_cstime=174724 /* 1747.24 s */}) = 1819843747
2207 pselect6(0, NULL, NULL, NULL, {tv_sec=1, tv_nsec=0}, NULL) = 0 (Timeout)
2207 wait4(-1, 0x7ffedc77b084, WNOHANG|WSTOPPED, NULL) = 0
2207 times({tms_utime=3026 /* 30.26 s */, tms_stime=6010 /* 60.10 s */, tms_cutime=369020 /* 3690.20 s */, tms_cstime=174724 /* 1747.24 s */}) = 1819843847
2207 pselect6(0, NULL, NULL, NULL, {tv_sec=1, tv_nsec=0}, NULL) = 0 (Timeout)
2207 wait4(-1, 0x7ffedc77b084, WNOHANG|WSTOPPED, NULL) = 0
2207 times({tms_utime=3026 /* 30.26 s */, tms_stime=6010 /* 60.10 s */, tms_cutime=369020 /* 3690.20 s */, tms_cstime=174724 /* 1747.24 s */}) = 1819843947
2207 pselect6(0, NULL, NULL, NULL, {tv_sec=1, tv_nsec=0}, NULL) = 0 (Timeout)
2207 wait4(-1, 0x7ffedc77b084, WNOHANG|WSTOPPED, NULL) = 0
It just loops like that forever.
Here is iptables setup
-P INPUT DROP
-P FORWARD DROP
-P OUTPUT ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 443 -m conntrack --ctstate NEW -j ACCEPT
-A INPUT -i eth0 -p tcp -m multiport --dports 22345:25000 -m conntrack --ctstate NEW -j ACCEPT
ip6tables:
-P INPUT DROP
-P FORWARD DROP
-P OUTPUT ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p ipv6-icmp -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 443 -m conntrack --ctstate NEW -j ACCEPT
-A INPUT -i eth0 -p tcp -m multiport --dports 22345:25000 -m conntrack --ctstate NEW -j ACCEPT