You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2009/11/24 15:22:47 UTC
DO NOT REPLY [Bug 48273] New: mod_proxy_fcgi sends broken
SCRIPT_FILENAME / PATH_INFO
https://issues.apache.org/bugzilla/show_bug.cgi?id=48273
Summary: mod_proxy_fcgi sends broken SCRIPT_FILENAME /
PATH_INFO
Product: Apache httpd-2
Version: 2.3-HEAD
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Other Modules
AssignedTo: bugs@httpd.apache.org
ReportedBy: ef-lists@email.de
When running mod_proxy_fcgi as a reverse proxy, it breaks the
SCRIPT_FILENAME environment variable.
Assuming the following configuration directive (in an otherwise smoothly
running Apache):
ProxyPass /imp fcgi://host:port
and a GET request to http://myhost/imp/index.php
This will set SCRIPT_FILENAME (from request_rec->filename) to
proxy:fcgi://host:file/index.php
In the maybe most popular case of PHP, this breaks PHP in determining
the correct script to call.
Even if SCRIPT_FILENAME is an Apache extension and not in the
CGI-standard, PHP reacts very sensitive to it, so it should be fixed
(although PHP might be configured in a way to ignore it).
When changing the above config directive to:
ProxyPass / fcgi://host:port/
a GET / results in PATH_INFO being set to proxy:fcgi://host:port/ ,
which obviously is bogus in the sense of the CGI standard.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
DO NOT REPLY [Bug 48273] mod_proxy_fcgi sends broken SCRIPT_FILENAME
/ PATH_INFO
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48273
--- Comment #6 from Edgar Frank <ef...@email.de> 2011-03-07 12:54:20 EST ---
Mark,
you're right, SCRIPT_FILENAME isn't part of any standard. IIRC this is/was a
workaround for broken CGI implementations.
I'd suggest to completely remove this anachronism. Isn't easy though, as this
is hardcoded in the httpd core and I'd think that beta stage is to late to
obsolete such a thing.
E.g. the according PHP code in FPM/CGI-SAPI is a complete mess of code trying
to patch this and that, trying to be smart here and there and guess what the
caller really meant. In pattern'ish this is a stove pipe system and I really
object to further extending this.
Indeed, we still have the namespace problem. But IMHO this is a problem of
remote FastCGI and a different issue. (Btw, I circumvent the namespace problem
by chrooting httpd and php-fpm and having the same directory layout).
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
DO NOT REPLY [Bug 48273] mod_proxy_fcgi sends broken SCRIPT_FILENAME
/ PATH_INFO
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48273
--- Comment #2 from Edgar Frank <ef...@email.de> 2009-11-24 23:46:45 UTC ---
(In reply to comment #1)
> I've met the same problem, but I didn't know how to configure PHP to ignore it,
> can you please describe your according PHP configuration?
IIRC, building PHP with --enable-discard-path should do the job. (I use PHP
with php-fpm as a FCGI backend) Maybe you have to set cgi.fix_path_info=On in
your php.ini/php-fpm.conf , too.
You can disable mod_proxy_fcgi from sending SCRIPT_FILENAME on the other hand,
which makes PHP parse PATH_INFO and SCRIPT_NAME. Open mod_proxy_fcgi.c in
$(apache_sourcedir)/modules/proxy, search for ap_add_common_vars(r); and add
insert following line after it:
apr_table_unset(r->subprocess_env, "SCRIPT_FILENAME");
Then, proceed with the usual build steps as described in the documentation.
Please consider this rather a quick hack than a clean solution.
Regards,
Edgar
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
DO NOT REPLY [Bug 48273] mod_proxy_fcgi sends broken SCRIPT_FILENAME
/ PATH_INFO
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48273
Dodou Wang <wa...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wangdong.08@gmail.com
--- Comment #1 from Dodou Wang <wa...@gmail.com> 2009-11-24 16:09:12 UTC ---
(In reply to comment #0)
I've met the same problem, but I didn't know how to configure PHP to ignore it,
can you please describe your according PHP configuration?
Thank you.
Dodou
> Even if SCRIPT_FILENAME is an Apache extension and not in the
> CGI-standard, PHP reacts very sensitive to it, so it should be fixed
> (although PHP might be configured in a way to ignore it).
>
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
DO NOT REPLY [Bug 48273] mod_proxy_fcgi sends broken SCRIPT_FILENAME
/ PATH_INFO
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48273
--- Comment #5 from Mark Montague <ma...@catseye.org> 2011-03-07 12:32:49 EST ---
Edgar,
Is SCRIPT_FILENAME part of any standard? If so, which one? (I've looked, but
it appears to be specific to Apache HTTP Server). If the use of
SCRIPT_FILENAME is not specified by any standard, then I'd say that if a
backend chooses to use this variable, it should expect to accommodate the
conventions Apache HTTP Server is following for it in the proxy modules. I can
see why a backend would choose to use it, as it contains information that
backends likely need which not available in SCRIPT_NAME. For example, if the
following directive is in effect
ProxyPass /test/ fcgi://127.0.0.1:9000/www/php-ssl/
and a request is made for
http://server-name/test/hello.php
then mod_proxy_fcgi sends the following to the backend:
SCRIPT_FILENAME=proxy:fcgi://127.0.0.1:9000/www/php-ssl/hello.php
SCRIPT_NAME=/test/hello.php
REQUEST_URI=/test/hello.php
SCRIPT_NAME unfortunately can not contain information about the backend's URI
namespace per RFC 3875.
Also, while HTTP is indeed the protocol used between the originator of the
request and the proxy (as indicated by the SERVER_PROTOCOL environment variable
passed to the backend as required by RFC 3875), mod_proxy_fcgi is speaking the
FastCGI protocol to php-fpm, not HTTP, as indicated in the ProxyPass directive
above. SCRIPT_FILENAME is not reflecting the URL that the user requested from
the proxy, it reflects what the proxy is requesting from the backend (granted,
it does not conform to RFC 1630, but if it did, php-fpm would still not be able
to handle it without modification).
I'm proposing that since I know of no standards that Apache HTTP Server is
violating in its current treatment of SCRIPT_FILENAME, and since this treatment
is standard across the various proxy modules, that php-fpm be modified to strip
out everything up through the port portion of SCRIPT_FILENAME, after which the
existing logic in php-fpm handles everything correctly.
Do you oppose this proposed solution? If you do, can you explain your reasons
more and/or propose a different solution? The bug has been open for nearly a
year and a half with no updates, and I'd like to see mod_proxy_fcgi work out of
the box with php-fpm when Apache HTTP Server 2.4 is released at the end of this
month or early next month.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
DO NOT REPLY [Bug 48273] mod_proxy_fcgi sends broken SCRIPT_FILENAME
/ PATH_INFO
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48273
Jim Jagielski <ji...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |DUPLICATE
--- Comment #7 from Jim Jagielski <ji...@apache.org> 2011-03-09 13:24:48 EST ---
*** This bug has been marked as a duplicate of bug 50851 ***
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
DO NOT REPLY [Bug 48273] mod_proxy_fcgi sends broken SCRIPT_FILENAME
/ PATH_INFO
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48273
Mark Montague <ma...@catseye.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mark@catseye.org
--- Comment #3 from Mark Montague <ma...@catseye.org> 2011-03-03 14:11:29 EST ---
The problem I see with Edgar's workaround in the general case is that
SCRIPT_NAME contains a URI in the proxy server's namespace. This may or may
not have meaning to the origin server. The reason to prefer SCRIPT_FILENAME is
that the URI in its value will be in the origin server's URI namespace.
I've submitted what I hope is a good a fix to the PHP project:
http://bugs.php.net/bug.php?id=54152
Feedback is welcome.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
DO NOT REPLY [Bug 48273] mod_proxy_fcgi sends broken SCRIPT_FILENAME
/ PATH_INFO
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48273
--- Comment #4 from Edgar Frank <ef...@email.de> 2011-03-07 11:57:36 EST ---
(In reply to comment #3)
proxy:fcgi://... isn't a URI according to RFC1630, so any backend doesn't need
to understand this at all.
Furthermore we're still talking HTTP (through [Fast]CGI), so the scheme should
remain http.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org