Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Strip proxy:fcgi:// just like proxy:balancer
Submitted By: Jacob Champion <champion.pxi gmail.com> Committed By: covener git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1747810 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Showing
2 changed files
with
19 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cab0bfbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to break apps relying on PATH_INFO for routing and using mod_rewrite to shorten urls (eg.
RewriteRule (.*) index.php/$1) in my mod_proxy_fcgi/php-fpm setup.When I request an url like
/testing/from httpd 2.4.23/.25, php-fpm just returns "File not found". However when bypassing the rewriting by requesting/index.php/testing/directly, it works. With httpd 2.4.16/.20, both urls work.I maxed out the log levels and compared the working to the non-working state. The only difference seems to be that the "proxy:fcgi://hostname:port" part is omitted from SCRIPT_FILENAME in .23/.25 .
What am I missing? Is there a way to work around this problem?
cab0bfbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will poke around tomorrow, can you share a little more about your fcgi/fpm config?
cab0bfbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I'm using
in the global httpd config. Switching to ProxyPassMatch or directly rewriting to a fcgi:// path doesn't make a difference.
In my app's
.htaccessI'm using the follwing rewriting rule:fpm (used 7.0.14 in my testing setup) has
cgi.fix_pathinfoenabled. Anything else you need to know?Thanks for getting back to me so quickly you two! :-)
cab0bfbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it seems that once we strip this var, php-fpm will make all different kinds of decisions because it doesn't recognize it's talking to Apache. One of those quirks is that in this rewrite scenario, is that we send a bad PATH_TRANSLATED value. It still has redirect: in the front of it and isn't actually TRANSLATED (filesystem-prefixed).
Other then removing this or guarding it behind some config where the user says they're not using php-fpm, I'm a bit stuck.
cab0bfbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REDIRECT_URL seems to be part of the culprit, it gets set for mod_rewrite in htaccess context and causes php-fpm (when it doesn't think Apache is the caller) to probably second-guess some of the other vars (I cannot follow exactly how it then goes wrong)
cab0bfbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it thinks it's operating under something like Action where SCRIPT_FILENAME is really the interpreter, so it looks at PATH_TRANSLATED. But mod_rewrite leaves that in a doubly-unusable state for this purpose -- it has a redirect: prefix and its value is not a script you expect fpm to run.
cab0bfbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for picking this up so quickly, very much appreciated! I've seen you took this discussion to the mailing list, where it belongs. I'll then just revert this patch against 2.4.25 for the time being and see what you guys will come up with.
cab0bfbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am looking with some consternation at https://github.com/php/php-src/blob/master/sapi/fpm/fpm/fpm_main.c#L1144 ...
cab0bfbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not great timing, because regular maintenance support for PHP 5.6 just ended; from now on, it's security fixes only for the next two years, although with a lot of begging and pleading, it might be possible to adjust this on the PHP side.
The code @jchampio linked to has evolved into that shape over time because it's not just two different web servers that are different, but also across versions or modules. Apache needs different treatment of
SCRIPT_FILENAME,PATH_INFOand so forth formod_php,mod_fcgi,mod_proxy_fcgi.One solution may be to have, for all modules and protocols, a
Viaheader field like "FastCGI/1.0 mod_proxy_fcgi (Apache/2.4)".A more permanent fix is to create a matrix of current modules, variables, and values, and figure out which ones differ across proxies/modules, and what the value should be for all of them. And then add tests to avoid regressions. A permanent "this is how it will behave now" would make it easy to implement this once and for all in PHP and others.
Either way, I think stuff like this needs to stop getting backported for minor versions. It's one of the issues I pointed out in my "A new release process?" email to the mailing list a few weeks back :(
cab0bfbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dzuelke
Though that would give you a better view into "what am I talking to" on the FastCGI server side, it also increases the surface for server developers to hack around our bugs instead of telling us what the bugs are. I'd rather give httpd administrators the ability to override CGI variables if necessary.
Agreed; we've been in varying states of discussion on the best way to move forward with this.
For the record, this was considered a bugfix when we put it in; a stronger release policy would not have changed anything. A
SCRIPT_FILENAMEof "proxy:fcgi://host:9000/var/www/html/script.php?query" is objectively useless for anyone who doesn't explicitly understand it's dealing with Apache. What none of us realized was that PHP-FPM had code put in place to detect this.cab0bfbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although true:
It is a clear indication that one is dealing with Apache
I have some further thoughts, but will share them on the dev@httpd.a.o list as proper :)