core icon indicating copy to clipboard operation
core copied to clipboard

OwnCloud requires cgi.fix_pathinfo = 1

Open PHLAK opened this issue 13 years ago • 10 comments

After installing OwnCloud 4.5.5 and logging in, I got the following:

owncloud

The issue had to do with /remote.php not properly displaying styles and JavaScript. I finally found the solution to my issue by reading through issue #367 which suggested setting cgi.fix_pathinfo = 1 in my php.ini file.

According to the notes in php.ini:

cgi.fix_pathinfo provides real PATH_INFO/PATH_TRANSLATED support for CGI. PHP's previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok what PATH_INFO is.For more information on PATH_INFO, see the cgi specs. Setting this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting of zero causes PHP to behave as before. Default is 1. You should fix your scripts to use SCRIPT_FILENAME rather than PATH_TRANSLATED. http://php.net/cgi.fix-pathinfo

It sounds like the way OwnCloud is implemented may be breaking best practices and should be revised to use SCRIPT_FILENAME rather than PATH_TRANSLATED to fix this issue.

Related issues: #195 & #367

For the record:

  • Ubuntu 12.04
  • Nginx 1.1.19
  • PHP 5.3.10
  • OwnCloud 4.5.5

PHLAK avatar Jan 15 '13 06:01 PHLAK

Should be fixed

karlitschek avatar Feb 09 '13 15:02 karlitschek

This is not fixed. The issue reference from @schiesbn is incorrect.

PHLAK avatar Feb 19 '13 15:02 PHLAK

I am having this exact issue while migrating from OC 4.0 to OC 4.5. With version 4.0 I had no problem at all.

I've followed #195 (mod_rewrite is on and works fine), #367 (AcceptPathInfo ON ) , #1189 ( cgi.fix_pathinfo = 1), #334 (mod_rewrite is enabled, Apache config: AllowOverride All, Apache config: DirectoryIndex index.php , cgi.fix_pathinfo again), among others.

I get 404 on http://owncloud.myserver/remote.php/core.css and http://owncloud.myserver/remote.php/core.js (same happens with https). I am running Owncloud 4.5, Apache/2.2.16 (Debian), PHP 5.3.3-7+squeeze14.

Any ideas?

gonetil avatar Feb 22 '13 20:02 gonetil

Please reopen if this issue has not been fixed in owncloud 5.0 master with the above pullrequest

BernhardPosselt avatar Feb 26 '13 21:02 BernhardPosselt

This issue is not fully resolved with the release of OwnCloud 5.0. The above fix only works when running Apache with mod_htaccess enabled. OwnCloud is still broken when ran under Nginx.

EDIT: From my understanding, it is a potential security risk to set cgi.fix_pathinfo to 1. See this article or this.

20130314-59a134

PHLAK avatar Mar 14 '13 17:03 PHLAK

@PHLAK nginx has nothing to do with this issue, check http://doc.owncloud.org/server/5.0/admin_manual/installation/installation_others.html

BernhardPosselt avatar Mar 14 '13 20:03 BernhardPosselt

Maybe linked to : https://github.com/owncloud/core/issues/692 ?

I think I have the same issue. I use Webmin/Virtualmin.

I've unactivate apache mod_deflate, and I've set cgi.fix_pathinfo = 1.

/remote.php/core.css send garbage stuff... What should I do ?

Capture

Edit : when I add : define("DEBUG", true); to config.php, I have that - it's not "perfect" : Capture

What should I do ?

EDIT 2 : When I go to httpS://owncloud.exemple.com/ , i have problem of first screenshoot again.

fgillig avatar Mar 22 '13 10:03 fgillig

I just posted this comment to issue #408 but I think it's related to your bug report here. I'll just paste what I wrote below. Your symptoms are pretty similar to mine.

" I've been trying to install owncloud 5.0.7 on an Ubuntu 12.04 system. I had the problem of double compression causing remote.php to produce css+js files with garbage content. I've finally successfully generated these files using this bit of code as a guide. Sadly, the code doesn't seem to do anything on my system.

As I mentioned I'm running Ubuntu, but nginx is my webserver. I'm also using php5-fpm to serve .php files. I believe php5-fpm having separate configuration files from cli php lead to my problem. I suspect this bit of code targets only cli php because by making the change zlib.output_compression Off in /etc/php5/fpm/php.ini file directly I was able to get the webpage looking properly again.

If there's anything else I could do to help, just let me know."

illogic-al avatar Jun 26 '13 14:06 illogic-al

The culprit is zlib compression. I still get the same error with OC 6.0.3. Here is a solution that worked for me. Edit /lib/private/minimizer.php and go to near line 37:

REPLACE: if(function_exists('apache_get_modules') && ini_get('zlib.output_compression') && in_array('mod_deflate', apache_get_modules())) {

WITH: if(ini_get('zlib.output_compression')) {

Doing so will force ini_set('zlib.output_compression', 'Off'); and render your files correctly. The problem seems to be in the if syntax: in my case [b]function_exists('apache_get_modules') returns nothing[/b], so ini_set('zlib.output_compression', 'Off') will not be executed, the css file will be compressed and the result is garbage in the browser.

I think the [b]&&[/b] should be [b]||[/b] perhaps?

nlublovary avatar Jun 08 '14 12:06 nlublovary

Bump. Are you guys accepting patches for this? I haven't tested with the latest github source but would be willing to do so and create a pull request with the above solution (if it's correct).

illogic-al avatar Sep 03 '14 05:09 illogic-al