I am using Ubuntu 15.04, Apache/2.4.10. I enabled mod_rewrite and mod_proxy_fcgi.

My apache config for fcgi is:

ProxyPassMatch ^/(.+\.(hh|php)(/.*)?)$ fcgi://$1

When I request it works perfectly

I added a rewrite rule like this:

RewriteRule ^foo index.php?country=de&handle=cleanmaster&offer=3

Now when I request Apache crash with this error:

[pid 4242:tid 140535432255360] AH00051: child pid 4539 exit signal Segmentation fault (11), possible coredump in /tmp/apache2-gdb-dump

If I look at the core dump, this is the stack trace:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  strlen () at ../sysdeps/x86_64/strlen.S:106

warning: Source file is more recent than executable.
106     movdqu  (%rax), %xmm12
(gdb) where
#0  strlen () at ../sysdeps/x86_64/strlen.S:106
#1  0x00007fd0f461ed37 in ap_fcgi_encoded_env_len ()
#2  0x00007fd0f03b328d in ?? () from /usr/lib/apache2/modules/mod_proxy_fcgi.so
#3  0x00007fd0f05c0653 in proxy_run_scheme_handler () from /usr/lib/apache2/modules/mod_proxy.so
#4  0x00007fd0f05c161c in ?? () from /usr/lib/apache2/modules/mod_proxy.so
#5  0x00007fd0f46182a0 in ap_run_handler ()
#6  0x00007fd0f46187e9 in ap_invoke_handler ()
#7  0x00007fd0f462dfac in ap_internal_redirect ()
#8  0x00007fd0eff98ea2 in ?? () from /usr/lib/apache2/modules/mod_rewrite.so
#9  0x00007fd0f46182a0 in ap_run_handler ()
#10 0x00007fd0f46187e9 in ap_invoke_handler ()
#11 0x00007fd0f462e682 in ap_process_async_request ()
#12 0x00007fd0f462b1f0 in ?? ()
#13 0x00007fd0f4621b10 in ap_run_process_connection ()
#14 0x00007fd0f09e1b0b in ?? () from /usr/lib/apache2/modules/mod_mpm_event.so
#15 0x00007fd0f3abc6aa in start_thread (arg=0x7fd0e77fe700) at pthread_create.c:333
#16 0x00007fd0f37f1eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

BTW if I disable fcgi, rewrite rule works fine and the correct file gets shown. In this case it just don't go through fcgi and of course source file gets downloaded. I believe something goes wrong with mix of rewrite and fcgi

  • It looks like a bug. In your gdb session, you could print out elts[i].key and elts[i].val when you are in frame 1. It is something like an "internal environment variable" with a null value? – covener Dec 26 '15 at 20:20

It seems probable that our own issues stemmed from our Chef configuration installing httpd, PHP-FPM and PHP itself from two different sources (EPEL vs IUS).

  • Can you be more specific? This isn't much of an answer as it stands. – Michael Hampton Jul 21 '16 at 21:32

I had a similar problem. Turns out that in Apache 2.4 you cannot have the mod_geoip option 'GeoIPScanProxyHeaders' set to 'On' at the same time that 'mod_remoteip' is enabled. 'GeoIPScanProxyHeaders' is a setting for obtaining the client IP address for use by 'mod_geoip'. Instead, 'mod_remoteip' should be preferred and 'mod_geoip' will use the findings of 'mod_remoteip'. Setting 'GeoIPScanProxyHeaders' and 'mod_remoteip' at the same time, breaks mod_rewite, at least as it relates to php-fpm.


We had the same problem on Ubuntu 16.04 when attempting to migrate a configuration which had worked fine on CentOS.

I found a useful workaround - changing the RewriteRule to use a handler flag to set the target fcgid server to proxy to, rather than using ProxyPassMatch, allowed requests to function as originally designed:

RewriteEngine On
# Force all non-files to go via fcgi proxy bootstrap file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ "-" [QSA,L,H=proxy:fcgi://]
# Force all php files to go via fcgi proxy verbatim
RewriteCond "%{REQUEST_FILENAME}" ".php$"
RewriteRule ^ "-" [QSA,L,H=proxy:fcgi://{REQUEST_FILENAME}]

Note that the above configuration handles setting the environment passed to fcgi slightly differently than a ProxyPass configuration, you may need to tweak the handling of the environment on the receiving side to get you application to interpret the path correctly. For example, we found adding the following to our receiving index.php file useful with our PHP-FPM setup:

$_SERVER['SCRIPT_NAME'] = '/' . __FILE__;

The above being said, given that apache processes are segfaulting with valid configuration, I'd expect this to be resolvable for the RewriteRule/ProxyPassMatch configuration by reporting this to the maintainers of the ubuntu package, who potentially need to rebuild these with a changed environment.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.