logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: mod_proxy_fcgi & php-cgi troubles
Author
nono303



Joined: 20 Dec 2016
Posts: 191
Location: Lille, FR, EU

PostPosted: Fri 12 Jan '18 15:20    Post subject: mod_proxy_fcgi & php-cgi troubles Reply with quote

Hi,
I actually try httpd & php with mod_proxy_fcgi
PHP 7.2 x64 NTS launched with
Code:
php-cgi.exe -b 127.0.0.1:9000

httpd apachelounge x64 2.4.29 configured with:
Code:
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
ProxyFCGIBackendType GENERIC
<Files ~ "\.(php|phtml)$">
    SetHandler "proxy:fcgi://127.0.0.1:9000/"
</Files>

That’s natively doesn’t work and return a "No input file specified" on page.
So I've tried different configuration on apache with loglevel trace8 to log SCRIPT_NAME CgiEnv value.
Here are the results:
Code:
ProxyFCGIBackendType GENERIC & SetHandler "proxy:fcgi://127.0.0.1:9000/"
[proxy_fcgi:trace8] mod_proxy_fcgi.c(385) AH01062: sending env var 'SCRIPT_FILENAME' value '/C:/httpd/www/test.php'

ProxyFCGIBackendType GENERIC & SetHandler "proxy:fcgi://127.0.0.1:9000#"
[proxy_fcgi:trace8] mod_proxy_fcgi.c(385) AH01062: sending env var 'SCRIPT_FILENAME' value '/httpd/www/test.php'

ProxyFCGIBackendType GENERIC & SetHandler "proxy:fcgi://127.0.0.1:9000"
[proxy:error] AH00898: URI cannot be parseC: fcgi://127.0.0.1:9000C:/httpd/www/test.php returned by /test.php

ProxyFCGIBackendType FPM & SetHandler "proxy:fcgi://127.0.0.1:9000"
[proxy:error] AH00898: URI cannot be parseC: fcgi://127.0.0.1:9000C:/httpd/www/test.php returned by /test.php

ProxyFCGIBackendType FPM & SetHandler "proxy:fcgi://127.0.0.1:9000#"
[proxy_fcgi:trace8] mod_proxy_fcgi.c(385) AH01062: sending env var 'SCRIPT_FILENAME' value 'proxy:fcgi://127.0.0.1:9000#C:/httpd/www/test.php'

ProxyFCGIBackendType FPM & SetHandler "proxy:fcgi://127.0.0.1:9000/"
[proxy_fcgi:trace8] mod_proxy_fcgi.c(385) AH01062: sending env var 'SCRIPT_FILENAME' value 'proxy:fcgi://127.0.0.1:9000/C:/httpd/www/test.php'

So either I miss something or it didn't work on Windows...
Is there somebody having a working conf?

I temporary make a dirty (my C is rusty) but functional patch on mod_proxy_fcgi.c
Code:
/modules/proxy/mod_proxy_fcgi.c"
@@ -357,6 +357,10 @@ static apr_status_t send_environment(proxy_conn_rec *conn, request_rec *r,
          if (newfname) {
             newfname = ap_strchr(newfname, '/');
+                       // Windows
+                       if ((ap_strstr(newfname, ":/")) != NULL)
+                               memmove(newfname, newfname+1, strlen(newfname));
+                       ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01078) "SCRIPT_FILENAME %s", newfname);
             r->filename = newfname;
         }
     }
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Thu 18 Jan '18 23:33    Post subject: Reply with quote

My best working config was

Code:

<VirtualHost *:80>
   ServerName fpm.local.apachehaus.de

   DirectoryIndex index.php

   CustomLog "C:\nul" common
   
   <IfModule proxy_fcgi_module>
         # Enable http authorization headers
         <IfModule setenvif_module>
               SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
         </IfModule>
ProxyPassMatch ^(.*\.php(.*)?)$ fcgi://127.0.0.1:9000/c:/Users/mariobrandt/work/$1
   </IfModule>
   DirectoryIndex /index.php index.php

   DocumentRoot "/Users/mario/work"

   <Directory "/Users/mario/work">
      Options Indexes FollowSymLinks
      AllowOverride All
      Require all
   </Directory>
</VirtualHost>


however I use now fcgid only. Works fine and stable and isn't slower than fpm.
Back to top
nono303



Joined: 20 Dec 2016
Posts: 191
Location: Lille, FR, EU

PostPosted: Fri 19 Jan '18 16:25    Post subject: Reply with quote

Thanks for the feedback!

Also using fcgid only now but wanted to test scalling & failover with php-cgi-spawner...
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3049
Location: Hilversum, NL, EU

PostPosted: Wed 07 Feb '18 13:14    Post subject: Reply with quote

The following I read at the article in post www.apachelounge.com/viewtopic.php?p=36433


⚠️ If you’re using Apache 2.4.25+, you must specify this directive:

ProxyFCGIBackendType GENERIC


Only necessary for Apache 2.4.26 and higher versions, because this release introduced a new behavior in the FCGI protocol handled by the mod_proxy_fcgi module.
If you don’t specify this directive, you will encounter a No input file specified. error, because it’s related to some proxy:fcgi:// string that’s passed to PHP that is not interpreted correctly.

This behavior is not needed when using Apache + php-fpm, because we can rely on a unix socket.
Back to top
bagu



Joined: 06 Jan 2011
Posts: 187
Location: France

PostPosted: Wed 07 Feb '18 23:33    Post subject: Reply with quote

Excuse me, but, is there a benefit to use php trough proxy and not fastcgi ?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Thu 08 Feb '18 15:50    Post subject: Reply with quote

bagu wrote:
Excuse me, but, is there a benefit to use php trough proxy and not fastcgi ?


Well I think that fcgid is the best solution, still.
Back to top


Reply to topic   Topic: mod_proxy_fcgi & php-cgi troubles View previous topic :: View next topic
Post new topic   Forum Index -> Apache