nextcloud / documentation

📘 Nextcloud documentation
https://docs.nextcloud.com
Other
492 stars 1.73k forks source link

PHP-FPM: Hint for using with Nextcloud and Apache #750

Open Pantos opened 6 years ago

Pantos commented 6 years ago

Hello,

there seems to be a problem to login in with apps if php-fpm is configured in httpd.conf via 'ProxyPassMatch'. It works perfect using

<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>

Maybe an interesting hint on https://docs.nextcloud.com/server/13/admin_manual/installation/source_installation.html.

c0fe commented 6 years ago

Can't recreate.

brad2014 commented 5 years ago

I also reproduce in NC 15.0.4 under Apache 2.4.34 and php-fpm 7.2.17 that redirecting using ProxyPassMatch breaks handling of files containing spaces (e.g. cannot delete, per nextcloud/server#1858 and nextcloud/server#8083).

I think it would be helpful to add to the manual under php-fpm configuration notes something like the following

Include the following lines in your Apache configuration file to handle php files using php-fpm:

<IfModule mod_proxy_fcgi.c>
<FilesMatch \..php$>
SetHandler SetHandler "proxy:fcgi://127.0.0.1:9000/"  # for php-fpm running on localhost port 9000
</FilesMatch>
</IfModule>

Note: do not use ProxyPassMatch - it breaks handling of cloud files with spaces or special characters in their filenames.

Orteko commented 5 years ago

Confirming that I can reproduce the same issue with a fresh install with the following package versions:

Nextcloud: 16.0.1 PHP: 7.3.5-1+ubuntu18.04.1+deb.sury.org+1 Apache: 2.4.39-1+ubuntu18.04.1+deb.sury.org+1

Switching from a ProxyPassMatch directive to a FilesMatch directive fixes the issue - I suspect the underlying issue is that PATH_INFO is missing (from 2.4.11 onwards?) when using ProxyPassMatch (https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html#env).

Old:

ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/run/php/php-fpm-site.sock|fcgi://localhost/srv/www/site/content"

New:

<FilesMatch "\.php$">
    SetHandler "proxy:unix:/run/php/php-fpm-site.sock|fcgi://localhost/"
</FilesMatch>

# Optional but seems recommended for performance reasons
<Proxy "fcgi://localhost/" enablereuse=on max=10>
</Proxy>
skjnldsv commented 5 years ago

@Orteko could you open a pull request with this fix and some documentation? :)

Orteko commented 5 years ago

@skjnldsv Will try and get some time to write it up although probably won't be for a couple of days.

wiswedel commented 3 years ago

@Orteko Are you still in for opening that PR?

joshtrichards commented 1 year ago

I'm not sure this is much of an issue anymore.

Plus FilesMatch is more flexible (e.g. you can check for the existence of a file before triggering the handler).

I suspect a lot of came up from folks running configs (or following tutorials) that predate Apache ~2.4.10 (July 2014).