mod_security prevents Apache from starting - no errors - apache

I installed mod_security 2.8.0 on my Apache 2.4 installation. I copied the yajl.dll into my bin folder, the .so file into my modules, added the configuration as the readme suggested, but when I start Apache, it fails.
But it only fails if I specify rules (I tried a lot of different ones, one at a time). Every time there is a rule, Apache fails to start.
If I go with only
SecRuleEngine On
SecDefaultAction "deny,phase:2,status:403"
Then it works fine. The error log shows only:
[Mon May 19 11:24:10.010299 2014] [:notice] [pid 2820:tid 496] ModSecurity for Apache/2.8.0 (http://www.modsecurity.org/) configured.
[Mon May 19 11:24:10.010299 2014] [:notice] [pid 2820:tid 496] ModSecurity: APR compiled version="1.5.0"; loaded version="1.5.0"
[Mon May 19 11:24:10.010299 2014] [:notice] [pid 2820:tid 496] ModSecurity: PCRE compiled version="8.34 "; loaded version="8.34 2013-12-15"
[Mon May 19 11:24:10.010299 2014] [:notice] [pid 2820:tid 496] ModSecurity: LUA compiled version="Lua 5.1"
[Mon May 19 11:24:10.010299 2014] [:notice] [pid 2820:tid 496] ModSecurity: LIBXML compiled version="2.9.1"
I.e. no errors. If I add a rule that is misconfigured (missing ID) it will log it here, but as you can see it doesn't - but Apache won't start.
System is Windows Server 2008 R2 64 bit.

I don't know if this helps, but I had this problem just minutes ago, and diagnosed that the mod_security installation changed my server root in the httpd_conf to "c:/apache24/" when there was no such file on my system, I changed it back to "c:/xampp/apache/" and it started up just fine again, no probs.

Related

503 Error On Fedora 22 Server Using Apache 2.4 and Mono

I am currently attempting to setup a home webserver. I have a lot of experience programming in C# and have been using Visual Studio and IIS for years. I recently decided to make the move to Linux and have been rebuilding my code bases using MonoDevelop. I have them compiling on my development machine, so I am setting up a home server with Fedora 22 Server, and Apache 2.4.
Using nothing but the default configuration the server is able to serve html pages without a problem, but when I installed Mono, and its dependencies, I have been getting various errors, and they are not detailed enough for someone with my limited experience to resolve. I have spent the entire week working on the issue, and here is where I am stuck.
When browsing to http://71.41.214.194/LDC-Demo/index.aspx, I get a "503 Service Unavailable" error in the browser. When looking at the Apache Error log I get the following:
[Fri Oct 09 15:22:41.809588 2015] [:error] [pid 7577] Failed to connect to mod-mono-server after several attempts to spawn the process.
Since that is not enough to discern the issue, I restarted Apache and tried to reload the page (I was hoping for a related error that could help me chase down the problem)
[Fri Oct 09 15:38:22.000257 2015] [mpm_prefork:notice] [pid 7564] AH00170: caught SIGWINCH, shutting down gracefully
[Fri Oct 09 15:38:23.011225 2015] [:alert] [pid 7564] (13)Permission denied: Failed to acquire dashboard lock before destroying the dashboard
[Fri Oct 09 15:38:23.011668 2015] [:alert] [pid 7564] (13)Permission denied: Failed to acquire dashboard lock before destroying the dashboard
[Fri Oct 09 15:38:23.011770 2015] [:alert] [pid 7564] (13)Permission denied: Failed to acquire dashboard lock before destroying the dashboard
[Fri Oct 09 15:38:24.068911 2015] [core:notice] [pid 7641] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Fri Oct 09 15:38:24.069933 2015] [suexec:notice] [pid 7641] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globa$
[Fri Oct 09 15:38:24.079961 2015] [auth_digest:notice] [pid 7641] AH01757: generating secret for digest authentication ...
[Fri Oct 09 15:38:24.080817 2015] [lbmethod_heartbeat:notice] [pid 7641] AH02282: No slotmem from mod_heartmonitor
[Fri Oct 09 15:38:24.088966 2015] [mpm_prefork:notice] [pid 7641] AH00163: Apache/2.4.16 (Fedora) mod_mono/3.12 configured -- resuming normal operations
[Fri Oct 09 15:38:24.088993 2015] [core:notice] [pid 7641] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Fri Oct 09 15:38:36.414478 2015] [:error] [pid 7651] Failed to connect to mod-mono-server after several attempts to spawn the process.
After researching each of these messages to the best of my ability, I could not find anything that was related to the issue. I did find that I could see some more details if I ran the command "journalctl -xe -cat".
Started The Apache HTTP Server.
mono[7646]: segfault at 5 ip 0000000000512710 sp 00007fffa85f01b0 error 6 in mono-sgen[400000+34d000]
<audit-1130> pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=httpd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Unregistered Authentication Agent for unix-process:7633:25881589 (system bus name :1.83, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
<audit-1400> avc: denied { execmem } for pid=7649 comm="mono" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=process permissive=0
<audit-1400> avc: denied { execmem } for pid=7649 comm="mono" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=process permissive=0
<audit-1701> auid=4294967295 uid=48 gid=48 ses=4294967295 subj=system_u:system_r:httpd_t:s0 pid=7649 comm="mono" exe="/usr/bin/mono-sgen" sig=11
mono[7649]: segfault at 5 ip 0000000000512710 sp 00007ffe5ca30440 error 6 in mono-sgen[400000+34d000]
Not saving repeating crash in '/usr/bin/mono-sgen'
Not saving repeating crash in '/usr/bin/mono-sgen'
<audit-1400> avc: denied { sigchld } for pid=7647 comm="abrt-hook-ccpp" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=0
Failed to create core_backtrace: waitpid failed: Permission denied
Blacklisted package 'mono-core'
'post-create' on '/var/spool/abrt/ccpp-2015-10-09-15:38:24-7644' exited with 1
Deleting problem directory '/var/spool/abrt/ccpp-2015-10-09-15:38:24-7644'
<audit-1400> avc: denied { execmem } for pid=7661 comm="mono" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=process permissive=0
<audit-1400> avc: denied { execmem } for pid=7661 comm="mono" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=process permissive=0
<audit-1701> auid=4294967295 uid=48 gid=48 ses=4294967295 subj=system_u:system_r:httpd_t:s0 pid=7661 comm="mono" exe="/usr/bin/mono-sgen" sig=11
mono[7661]: segfault at 5 ip 0000000000512710 sp 00007ffed5a32ee0 error 6 in mono-sgen[400000+34d000]
Not saving repeating crash in '/usr/bin/mono-sgen'
There is a lot more information in these messages, but I am still having a problem finding the cause. The last 5 lines are repeated three times.
I have tried making modifications to the apache config file (httpd.conf) as well as to the mod_mono.conf file, but nothing seems to get me past the problem.
In my current configuration the mod_mono.conf file is unmodified from the default configuration, and the only change that I have made to httpd.conf is to add a virtual host section as follows:
<VirtualHost *:80>
ServerName LDC-Demo
ServerAdmin root#localhost
ServerAlias LDC-Demo
DocumentRoot /var/www/html/LDC-Demo/
MonoServerPath LDC-Demo "/usr/bin/mod-mono-server4"
MonoDebug LDC-Demo true
MonoSetEnv LDC-Demo MONO_IOMAP=all
MonoApplications LDC-Demo "/:/var/www/html/LDC-Demo"
<Location "/LDC-Demo">
Allow from all
Order allow,deny
MonoSetServerAlias LDC-Demo
SetHandler mono
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
</Location>
</VirtualHost>
Any ideas would be appreciated, as I stated above, I have been working on this all week, and am not making much progress.
I entered this above as a comment, but I intended to answer the question.
I figuered it out. Fedora runs SELinux, and it was interfering with the permissions needed for mod_mono to run. To see these settings I ran the command: getenforce Then to temporarily change the setting I used the following command: setenforce 0 Finally, restart Apache: apachectl restart I refreshed the web browser and the page loaded correctly. To make the setting permanant, edit the selinux file: nano /etc/sysconfig/selinux I rebooted the server, and tried to load the webpage again. Eureka! everything is working.

HHVM With FCGI and APACHE show 500 Internal Server Error

Hy,
I have succesfully installed hhvm on my ubuntu 14.04 server. I can run codes from terminal with the following code.
hhvm test.php
The problem is when I want to access my webpage from browser I get 500 Internal Server Error. In the error log I have found the following lines.
[Fri Apr 24 14:26:37.377998 2015] [fcgid:warn] [pid 40696] (104)Connection reset by peer: [client 192.168.65.221:50382] mod_fcgid: error reading data from FastCGI server
[Fri Apr 24 14:26:37.378029 2015] [core:error] [pid 40696] [client 192.168.65.221:50382] End of script output before headers: index.php
I am using Apache web server with ISPConfig 3 to handle domains and other stuff.
Does anyone know how to handle this situation?
Thanks in advance, David.

Apache2 and mod_wsgi: Truncated or oversized response headers received from daemon process

My application is running with an Apache 2 server using mod_wsgi, Flask, and Python 2.7. Oddly enough, the application crashes when the page refreshes. For me, this happens exactly on every other refresh. You can see it here. Furthermore, in Chrome, if I open the web inspector tool, the program does not crash.
In the logs, I see:
[Tue Apr 14 13:45:29.137444 2015] [wsgi:error] [pid 32713] [client 146.203.54.32:58816] Truncated or oversized response headers received from daemon process 'localhost:80': /etc/g2e/htdocs/g2e
[Tue Apr 14 13:45:29.671493 2015] [core:notice] [pid 28845] AH00052: child pid 640 exit signal Segmentation fault (11)
[Tue Apr 14 13:45:29.671520 2015] [wsgi:info] [pid 28845] mod_wsgi (pid=640): Process 'localhost:80' has died, deregister and restart it.
[Tue Apr 14 13:45:29.671524 2015] [wsgi:info] [pid 28845] mod_wsgi (pid=640): Process 'localhost:80' terminated by signal 11
[Tue Apr 14 13:45:29.671527 2015] [wsgi:info] [pid 28845] mod_wsgi (pid=640): Process 'localhost:80' has been deregistered and will no longer be monitored.
...
FWIW, I am using
Linux 3.16.7-7-desktop #1 SMP PREEMPT Wed Dec 17 18:00:44 UTC 2014 (762f27a) x86_64 x86_64 x86_64 GNU/Linux
Any help is appreciated.
I may have a tweak. I had this problem but now it's working somehow.
I tried to run mod_wsgi as a daemon. My application didn't work and I had this error message in the logs.
however running mod_wsgi as non-daemon worked, for instance
python manage.py runmodwsgi --reload-on-changes # for Django
So I once again launched it then killed it.
my app is still running :)
(mod_wsgi 4.4.[1-13], apache2, python 2.7, Django 1.7, Debian8 fresh install, with or without virtualenv)

Anyone succeeded to Install Laravel on Apache2 with fcgi?

I have successfully installed Laravel on Apache2 with php as a module. The instructions are simple. However, when I try with fcgi it does not work. So it has to do with the server configuration. After I visited http://<mylaraveldomain> (domain not public), I looked at /var/log/apache2/error.log and got this error message
[Thu Mar 26 22:52:34.012794 2015] [fcgid:warn] [pid 30834] (104)Connection reset by peer: [client 65.92.253.153:7785] mod_fcgid: error reading data from FastCGI server
[Thu Mar 26 22:52:34.012862 2015] [core:error] [pid 30834] [client 65.92.253.153:7785] End of script output before headers: php-fcgi-wrapper
[Thu Mar 26 22:52:39.826939 2015] [fcgid:error] [pid 30830] mod_fcgid: process /var/www/default/cgi-bin/php5-default/php-fcgi-wrapper(31115) exit(communication error), get unexpected signal 11
I also looked at all other log files in /var/log recently modified after visiting the URL, but no additional useful info was found. Should I look elsewhere? It is not that fcgi is not working, because if I put a file test.php in laravel public folder I can read it fine at the URL http://<mylaraveldomain>/test.php. Is there some special configuration settings to make laravel works with fcgi ? It is possible that it is specific to my installation of fcgi. So, I would like to know if others have succeeded to install laravel with fcgi on apache2. I am on Ubuntu and I made a recent apt-get upgrade.
I checked syslog and there was additional info. I could see a segment fault. I guessed it could be cache management issue. I commented out the line zend_extension=opcache.so in the file /etc/php5/apache2/conf.d/05-opcache.ini and it worked. Of course, this is only a work around.

XAMPP Apache startup issues

This is first problem like that on my PC. Honestly saying I tried all solutions from the first pages of google and no one did work. I was able to start the server without any problem one month ago but today I'm starting it and it automatically stops. I tried to change port from 80 to 8080, 1337, 9999 and no one did work so I don't think it's a port problem(I've also tried to change the port in SSL config of apache) and few other solutions shown on few pages but I cant! It still stops, I don't know if a satan controlls the ports or what. Please help me without posting links because I tried them all. I don't really know if it's a good problem for stackoverflow but it seems to be really annoying so I've decided to post it here. That would be nice to see any help. I don't care if you don't like the problem and give me the magic downvote, all I need is the solution.
[Thu Aug 08 16:42:39.843750 2013] [mpm_winnt:notice] [pid 3324:tid 188] AH00455: Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7 configured -- resuming normal operations
[Thu Aug 08 16:42:39.843750 2013] [mpm_winnt:notice] [pid 3324:tid 188] AH00456: Server built: Aug 18 2012 12:41:37
[Thu Aug 08 16:42:39.843750 2013] [core:notice] [pid 3324:tid 188] AH00094: Command line: 'd:\\xampp\\apache\\bin\\httpd.exe -d D:/xampp/apache'
[Thu Aug 08 16:42:39.859375 2013] [mpm_winnt:notice] [pid 3324:tid 188] AH00418: Parent: Created child process 3472
[Thu Aug 08 16:42:41.140625 2013] [mpm_winnt:crit] [pid 3472:tid 1884] (OS 10022)An invalid argument was supplied. : AH00405: Child: WSASocket failed to open the inherited socket
[Thu Aug 08 16:42:41.140625 2013] [mpm_winnt:crit] [pid 3324:tid 188] AH00427: Parent: child process exited with status 3 -- Aborting.
i was having the same issue however after i restart the computer it went ok...
that happens because 'system' is using port 80...
try to:
Close XAMPP
Open "SERVICES.MSC"
Stop "Web Deployment Agent Service"
In my case this was apparently caused by Winsock2 corruption. In case anyone else experiences this issue, try the Fix It link at the bottom of this page from Microsoft:
http://support.microsoft.com/kb/811259/en
(as recommended here https://community.apachefriends.org/f/viewtopic.php?f=16&t=49824)
That solved it for me; changing the port and other things mentioned here did not.