Bug + Fix - PHP-FPM + fastcgi && mod_proxy_fcgi + sockets not working together

Discussion in 'Developers' Forum' started by ztk.me, Feb 13, 2016.

  1. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    I don't know if this issue has ben filed yet but it just came to my annoyance:
    Setting up Apache with mod_fastcgi + mod_proxy_fcgi and using PHP-FPM with socket option results in error 503.
    The vhost-template does respect the socket option for _fastcgi but gets overriden a few lines later by _proxy_fcgi which just doesn't handle sockets yet.
    Another issue might be missing Authorization Headers by using proxy_fcgi.

    My workaround for these issue is to change


    look for the current lines
    <IfModule mod_proxy_fcgi.c>
        ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ fcgi://<tmpl_var name='fpm_port'><tmpl_var name='web_document_root'>/$1
    and make them look like
                    <IfModule mod_proxy_fcgi.c>
                            SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
                            <tmpl_if name='use_socket'>
                                    ProxyPassMatch "^/(.*\.php[345]?(/.*)?)$" "unix:<tmpl_var name='fpm_socket'>|fcgi://localhost{tmpl_var name='document_root'}/web"
                                    ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ fcgi://<tmpl_var name='fpm_port'><tmpl_var name='web_document_root'>/$1
    This currently works well for me, I also tested .htaccess basic authorization and as I expected the credentials are passed to PHP.
    My System is Debian 8, so I use Apache 2.4, don't know wther the fix works for older versions.
    till likes this.
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Thank you for the patch!

    The apache modules mod_fastcgi and mod_proxy_fcgi should not be installed together on an ISPConfig server, ISPConfig requires for Debian to install mod_fastcgi, the mod_proxy_fcgi mode is for centos 7 only. Please see perfect server guides for the two OS. The functions in the mod_proxy_fcgi had been limited due to bugs in the version that ships with CentOS, so it is intended that sockets don't work as they crash on centos and ispconfig forces the socket mode to port mode when installed on a centos server.

    I added your post as feature request to support mod_proxy_fcgi on Debian in the bug tracker.

  3. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    Thank you for your time adding this as feature request. I do know according to perfect server setup it is not intended to do so, but it also tells ppl to use mpm-prefork and bunch of other stuff I ditched like 10 years already :)

    Some ppl might be using proxy_fcgi, still - I did not do much testing yet since I'm still playing around with it. I know socket support has been bad - but years pass by and I thought to give it a shot since it's easy to configure especially to workaround some issues with some non migrated configs for phpmyadmin and so on which still depends on mod_php.

    I don't know if there is a check to wether proxy_fcgi is loaded and one is selecting php-fpm socket option on GUI to give him a hint that it probably won't work or give errors / won't work instead of just ignoring the users choice to use sockets. Ppl do and want to play around and getting 500 because of this might be confusing and ask for support :).

    Another option would be to ignore proxy_fcgi entirely when socket option is set?!

    But besides all of it ... Adding the SetEnvIf directive would fix missing authorization headers for both socket and tcp configurations.

    https://wiki.apache.org/httpd/PHP-FPM ( Performance and Pitfalls )
    Last edited: Feb 13, 2016

Share This Page